Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1232713 > unrolled thread

[PATCH] drm/i915: fix task reference leak in i915_debugfs.c

Started byGeliang Tang <geliangtang@163.com>
First post2015-09-25 13:10 +0200
Last post2015-09-25 14:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] drm/i915: fix task reference leak in i915_debugfs.c Geliang Tang <geliangtang@163.com> - 2015-09-25 13:10 +0200
    Re: [PATCH] drm/i915: fix task reference leak in i915_debugfs.c Jani Nikula <jani.nikula@linux.intel.com> - 2015-09-25 13:20 +0200
      Re: [PATCH] drm/i915: fix task reference leak in i915_debugfs.c Daniel Vetter <daniel@ffwll.ch> - 2015-09-25 14:30 +0200

#1232713 — [PATCH] drm/i915: fix task reference leak in i915_debugfs.c

FromGeliang Tang <geliangtang@163.com>
Date2015-09-25 13:10 +0200
Subject[PATCH] drm/i915: fix task reference leak in i915_debugfs.c
Message-ID<qcz33-7Xt-11@gated-at.bofh.it>
Leak a task reference in i915_ppgtt_info(), add put_task_struct()
to fix it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 5615d3d..8797717 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2288,9 +2288,13 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
 
 	list_for_each_entry_reverse(file, &dev->filelist, lhead) {
 		struct drm_i915_file_private *file_priv = file->driver_priv;
+		struct task_struct *task;
 
-		seq_printf(m, "\nproc: %s\n",
-			   get_pid_task(file->pid, PIDTYPE_PID)->comm);
+		task = get_pid_task(file->pid, PIDTYPE_PID);
+		if (!task)
+			return -ESRCH;
+		seq_printf(m, "\nproc: %s\n", task->comm);
+		put_task_struct(task);
 		idr_for_each(&file_priv->context_idr, per_file_ctx,
 			     (void *)(unsigned long)m);
 	}
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1232720

FromJani Nikula <jani.nikula@linux.intel.com>
Date2015-09-25 13:20 +0200
Message-ID<qczcK-88V-19@gated-at.bofh.it>
In reply to#1232713
On Fri, 25 Sep 2015, Geliang Tang <geliangtang@163.com> wrote:
> Leak a task reference in i915_ppgtt_info(), add put_task_struct()
> to fix it.

Introduced by

commit 1c60fef535d143860d5bf6593e24ab6417f5227c
Author: Ben Widawsky <ben@bwidawsk.net>
Date:   Fri Dec 6 14:11:30 2013 -0800

    drm/i915: Dump all ppgtt


>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 5615d3d..8797717 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2288,9 +2288,13 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
>  
>  	list_for_each_entry_reverse(file, &dev->filelist, lhead) {
>  		struct drm_i915_file_private *file_priv = file->driver_priv;
> +		struct task_struct *task;
>  
> -		seq_printf(m, "\nproc: %s\n",
> -			   get_pid_task(file->pid, PIDTYPE_PID)->comm);
> +		task = get_pid_task(file->pid, PIDTYPE_PID);
> +		if (!task)
> +			return -ESRCH;
> +		seq_printf(m, "\nproc: %s\n", task->comm);
> +		put_task_struct(task);
>  		idr_for_each(&file_priv->context_idr, per_file_ctx,
>  			     (void *)(unsigned long)m);
>  	}
> -- 
> 1.9.1
>
>

-- 
Jani Nikula, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1232760

FromDaniel Vetter <daniel@ffwll.ch>
Date2015-09-25 14:30 +0200
Message-ID<qcAiv-1fs-33@gated-at.bofh.it>
In reply to#1232720
On Fri, Sep 25, 2015 at 02:16:07PM +0300, Jani Nikula wrote:
> On Fri, 25 Sep 2015, Geliang Tang <geliangtang@163.com> wrote:
> > Leak a task reference in i915_ppgtt_info(), add put_task_struct()
> > to fix it.
> 
> Introduced by
> 
> commit 1c60fef535d143860d5bf6593e24ab6417f5227c
> Author: Ben Widawsky <ben@bwidawsk.net>
> Date:   Fri Dec 6 14:11:30 2013 -0800
> 
>     drm/i915: Dump all ppgtt

Queued for -next, thanks for the patch.
-Daniel

> 
> 
> >
> > Signed-off-by: Geliang Tang <geliangtang@163.com>
> > ---
> >  drivers/gpu/drm/i915/i915_debugfs.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> > index 5615d3d..8797717 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -2288,9 +2288,13 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
> >  
> >  	list_for_each_entry_reverse(file, &dev->filelist, lhead) {
> >  		struct drm_i915_file_private *file_priv = file->driver_priv;
> > +		struct task_struct *task;
> >  
> > -		seq_printf(m, "\nproc: %s\n",
> > -			   get_pid_task(file->pid, PIDTYPE_PID)->comm);
> > +		task = get_pid_task(file->pid, PIDTYPE_PID);
> > +		if (!task)
> > +			return -ESRCH;
> > +		seq_printf(m, "\nproc: %s\n", task->comm);
> > +		put_task_struct(task);
> >  		idr_for_each(&file_priv->context_idr, per_file_ctx,
> >  			     (void *)(unsigned long)m);
> >  	}
> > -- 
> > 1.9.1
> >
> >
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web