From d1983f5cfa2317224ae527412e2a8f755976e5ab Mon Sep 17 00:00:00 2001 From: Martin Radev Date: Mon, 10 May 2021 14:45:22 +0300 Subject: [PATCH] gpu: nvgpu: Decrement CSS dmabuf ref cnt before ret The function gk20a_channel_cycle_stats does not decrement the dmabuf refcnt if vmapping it fails. This patch fixes it by decrementing the ref cnt before returning. NVGPU-397 NVGPU-415 Change-Id: Iae01ada710adb04fd4e4ba0371eccec5f8765254 Signed-off-by: Martin Radev Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2527190 Reviewed-by: svc_kernel_abi Reviewed-by: Alex Waterman Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 079e48dba..2bda5514d 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -179,8 +179,10 @@ int gk20a_channel_cycle_stats(struct nvgpu_channel *ch, int dmabuf_fd) #else virtual_address = dma_buf_vmap(dmabuf); #endif - if (!virtual_address) + if (!virtual_address) { + dma_buf_put(dmabuf); return -ENOMEM; + } priv->cyclestate_buffer_handler = dmabuf; ch->cyclestate.cyclestate_buffer = virtual_address;