The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Rakib Mullick <rakib.mullick@gmail.com>,
	Keith Packard <keithp@keithp.com>
Cc: akpm@linux-foundation.org,
	dri-devel <dri-devel@lists.freedesktop.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm, i915: Fix memory leak in i915_gem_busy_ioctl().
Date: Sat, 26 Nov 2011 10:57:22 +0000	[thread overview]
Message-ID: <e0d58a$2cdsbh@orsmga002.jf.intel.com> (raw)
In-Reply-To: <CADZ9YHgwcjz=mkMxWxV1pT7fH=6hgWTSP1s2wmG7h3N837QUoQ@mail.gmail.com>

On Sat, 26 Nov 2011 10:44:17 +0600, Rakib Mullick <rakib.mullick@gmail.com> wrote:
> On Mon, Nov 21, 2011 at 11:16 PM, Keith Packard <keithp@keithp.com> wrote:
> > On Mon, 21 Nov 2011 17:23:06 +0100, Daniel Vetter <daniel@ffwll.ch> wrote:
> >
> >> Indeed, nice catch (albeit totally unlikely to be hit, because the error
> >> only happens when the gpu ceases to progress in the ring, so imo not
> >> stable material). Keith, please pick this up for fixes, thanks.
> >
> > It's already there and queued for airlied :-)
> >
> Thank you guys for reviewing and taking the patch.
> 
> Now, while I was looking at the uses of i915_add_request(), I found
> the following code :
> 
>                         ret = i915_gem_flush_ring(ring, 0,
> I915_GEM_GPU_DOMAINS);
>                         request = kzalloc(sizeof(*request), GFP_KERNEL);
>                         if (ret || request == NULL ||
>                             i915_add_request(ring, NULL, request))
>                             kfree(request);
> 
> From above code, we might ended up by calling kfree(request) without
> allocating request. Though, it's unlikely cause if request is NULL
> then BUG_ON will be hit in i915_add_request(). So, to unify the callee
> uses of i915_add_request(), I'm proposing the following patch. Please
> let me know what do you guys think. If you guys agree, I can sent a
> formal patch.

kfree(NULL) is permitted and taken advantage of here along with the
short-circuiting behaviour of '||'.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2011-11-26 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 18:49 [PATCH] drm, i915: Fix memory leak in i915_gem_busy_ioctl() Rakib Mullick
2011-11-21 16:23 ` Daniel Vetter
2011-11-21 17:16   ` Keith Packard
2011-11-26  4:44     ` Rakib Mullick
2011-11-26 10:57       ` Chris Wilson [this message]
2011-11-26 16:29         ` Rakib Mullick
2011-11-26 16:53           ` Chris Wilson
2011-11-28  4:29             ` Rakib Mullick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='e0d58a$2cdsbh@orsmga002.jf.intel.com' \
    --to=chris@chris-wilson.co.uk \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=keithp@keithp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rakib.mullick@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox