summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2017-08-31 06:01:26 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-11 13:34:57 -0400
commit17451138cf60f5d64eed88cc5defd44981926d9d (patch)
treeea335a05d9e038876d42bcd8a73c56e3b60af1a5 /drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
parentde0ce3e017decadd3a5049477f17ba770ddf074c (diff)
gpu: nvgpu: hold ch ref when getting ch from fd
Fix a race condition in gk20a_get_channel_from_file() that returns a channel pointer from an fd: take a reference to the channel before putting the file ref back. Now the caller is responsible of releasing the channel reference eventually. Also document why dbg_session_channel_data has to hold a ref to the channel file instead of just the channel: that might deadlock if the fds were closed in "wrong" order. Change-Id: I8e91b809f5f7b1cb0c1487bd955ad6d643727a53 Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1549290 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
index 2c274f23..0d79b143 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c
@@ -354,6 +354,8 @@ static int nvgpu_gpu_ioctl_inval_icache(
354 nvgpu_mutex_acquire(&g->dbg_sessions_lock); 354 nvgpu_mutex_acquire(&g->dbg_sessions_lock);
355 err = g->ops.gr.inval_icache(g, ch); 355 err = g->ops.gr.inval_icache(g, ch);
356 nvgpu_mutex_release(&g->dbg_sessions_lock); 356 nvgpu_mutex_release(&g->dbg_sessions_lock);
357
358 gk20a_channel_put(ch);
357 return err; 359 return err;
358} 360}
359 361
@@ -393,6 +395,7 @@ static int nvgpu_gpu_ioctl_set_debug_mode(
393 err = -ENOSYS; 395 err = -ENOSYS;
394 nvgpu_mutex_release(&g->dbg_sessions_lock); 396 nvgpu_mutex_release(&g->dbg_sessions_lock);
395 397
398 gk20a_channel_put(ch);
396 return err; 399 return err;
397} 400}
398 401