[v2] drm/i915: Fix pid leak with banned clients
diff mbox series

Message ID 20191217170933.8108-1-tvrtko.ursulin@linux.intel.com
State New
Headers show
Series
  • [v2] drm/i915: Fix pid leak with banned clients
Related show

Commit Message

Tvrtko Ursulin Dec. 17, 2019, 5:09 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Get_pid_task() needs to be paired with a put_pid or we leak a pid
reference every time a banned client tries to create a context.

v2:
 * task_pid_nr helper exists! (Chris)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: b083a0870c79 ("drm/i915: Add per client max context ban limit")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Chris Wilson Dec. 17, 2019, 5:11 p.m. UTC | #1
Quoting Tvrtko Ursulin (2019-12-17 17:09:33)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Get_pid_task() needs to be paired with a put_pid or we leak a pid
> reference every time a banned client tries to create a context.
> 
> v2:
>  * task_pid_nr helper exists! (Chris)
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Fixes: b083a0870c79 ("drm/i915: Add per client max context ban limit")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@intel.com>

As used by others, so must be safe!
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 46b4d1d643f8..6618c0c6506c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -2194,8 +2194,7 @@  int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	ext_data.fpriv = file->driver_priv;
 	if (client_is_banned(ext_data.fpriv)) {
 		DRM_DEBUG("client %s[%d] banned from creating ctx\n",
-			  current->comm,
-			  pid_nr(get_task_pid(current, PIDTYPE_PID)));
+			  current->comm, task_pid_nr(current));
 		return -EIO;
 	}