From 58018f0c1b6c1957598ba58168ba9303b5617f35 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Wed, 6 Sep 2017 13:27:17 +0300 Subject: gpu: nvgpu: gv11b: hold ch ref when getting ch from fd Add gk20a_channel_put() pair for gk20a_get_channel_from_file() that now returns the channel with a reference. Also fix resource leaks in gv11b_tsg_ioctl_bind_channel_ex's error paths. Change-Id: Ib348219defa67163657ca534826f504ebc59497e Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1553276 Reviewed-by: svccoveritychecker Reviewed-by: svc-mobile-coverity Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index b0b1f9c4..87fbf010 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -33,21 +33,26 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, nvgpu_mutex_acquire(&sched->control_lock); if (sched->control_locked) { err = -EPERM; - goto done; + goto mutex_release; } err = gk20a_busy(g); if (err) { nvgpu_err(g, "failed to power on gpu"); - goto done; + goto mutex_release; } ch = gk20a_get_channel_from_file(arg->channel_fd); - if (!ch) - return -EINVAL; - if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) + if (!ch) { + err = -EINVAL; + goto idle; + } + if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) { ch->t19x.subctx_id = arg->subcontext_id; - else - return -EINVAL; + } else { + err = -EINVAL; + goto ch_put; + } + nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d", ch->chid, ch->t19x.subctx_id); @@ -56,8 +61,11 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, ch->t19x.runqueue_sel = 1; err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch); +ch_put: + gk20a_channel_put(ch); +idle: gk20a_idle(g); -done: +mutex_release: nvgpu_mutex_release(&sched->control_lock); return err; } -- cgit v1.2.2