diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2017-09-06 06:27:17 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-09-11 13:34:58 -0400 |
commit | 58018f0c1b6c1957598ba58168ba9303b5617f35 (patch) | |
tree | fb5a3906240daead0dd36020b68307d7f517c742 /drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | |
parent | a42d6029a5afdf4fb2b9538a56808fbf3908a8ed (diff) |
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 <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1553276
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 24 |
1 files changed, 16 insertions, 8 deletions
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, | |||
33 | nvgpu_mutex_acquire(&sched->control_lock); | 33 | nvgpu_mutex_acquire(&sched->control_lock); |
34 | if (sched->control_locked) { | 34 | if (sched->control_locked) { |
35 | err = -EPERM; | 35 | err = -EPERM; |
36 | goto done; | 36 | goto mutex_release; |
37 | } | 37 | } |
38 | err = gk20a_busy(g); | 38 | err = gk20a_busy(g); |
39 | if (err) { | 39 | if (err) { |
40 | nvgpu_err(g, "failed to power on gpu"); | 40 | nvgpu_err(g, "failed to power on gpu"); |
41 | goto done; | 41 | goto mutex_release; |
42 | } | 42 | } |
43 | 43 | ||
44 | ch = gk20a_get_channel_from_file(arg->channel_fd); | 44 | ch = gk20a_get_channel_from_file(arg->channel_fd); |
45 | if (!ch) | 45 | if (!ch) { |
46 | return -EINVAL; | 46 | err = -EINVAL; |
47 | if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) | 47 | goto idle; |
48 | } | ||
49 | if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) { | ||
48 | ch->t19x.subctx_id = arg->subcontext_id; | 50 | ch->t19x.subctx_id = arg->subcontext_id; |
49 | else | 51 | } else { |
50 | return -EINVAL; | 52 | err = -EINVAL; |
53 | goto ch_put; | ||
54 | } | ||
55 | |||
51 | nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d", | 56 | nvgpu_log(g, gpu_dbg_info, "channel id : %d : subctx: %d", |
52 | ch->chid, ch->t19x.subctx_id); | 57 | ch->chid, ch->t19x.subctx_id); |
53 | 58 | ||
@@ -56,8 +61,11 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, | |||
56 | ch->t19x.runqueue_sel = 1; | 61 | ch->t19x.runqueue_sel = 1; |
57 | 62 | ||
58 | err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch); | 63 | err = ch->g->ops.fifo.tsg_bind_channel(tsg, ch); |
64 | ch_put: | ||
65 | gk20a_channel_put(ch); | ||
66 | idle: | ||
59 | gk20a_idle(g); | 67 | gk20a_idle(g); |
60 | done: | 68 | mutex_release: |
61 | nvgpu_mutex_release(&sched->control_lock); | 69 | nvgpu_mutex_release(&sched->control_lock); |
62 | return err; | 70 | return err; |
63 | } | 71 | } |