All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Felix Monninger <felix.monninger@gmail.com>
Subject: Re: [PATCH v2] drm: Release reference from blob lookup after replacing property
Date: Wed, 26 Oct 2016 10:48:07 +0300	[thread overview]
Message-ID: <20161026074807.GU4617@intel.com> (raw)
In-Reply-To: <20161025212808.3908-1-chris@chris-wilson.co.uk>

On Tue, Oct 25, 2016 at 10:28:08PM +0100, Chris Wilson wrote:
> From: Felix Monninger <felix.monninger@gmail.com>
> 
> drm_property_lookup_blob() returns a reference to the returned blob, and
> drm_atomic_replace_property_blob() takes a references to the blob it
> stores, so afterwards we are left owning a reference to the new_blob that
> we never release, and thus leak memory every time we update a property
> such as during drm_atomic_helper_legacy_gamma_set().
> 
> v2: update credentials, drm_property_unreference_blob() is NULL safe and
> NULL is passed consistently to it throughout drm_atomic.c so do so here.
> 
> Reported-by: Felix Monninger <felix.monninger@gmail.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98420
> Signed-off-by: Felix Monninger <felix.monninger@gmail.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Cc: stable@vger.kernel.org
Fixes: 5488dc16fde7 ("drm: introduce pipe color correction properties")
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

The single return path bikeshed looked OK to me too, so my r-b can
be applied there as well, if people prefer that version.

> ---
>  drivers/gpu/drm/drm_atomic.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 1b5a32df9a9a..e0760c138355 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -416,18 +416,21 @@ drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc,
>  					 ssize_t expected_size,
>  					 bool *replaced)
>  {
> -	struct drm_device *dev = crtc->dev;
>  	struct drm_property_blob *new_blob = NULL;
>  
>  	if (blob_id != 0) {
> -		new_blob = drm_property_lookup_blob(dev, blob_id);
> +		new_blob = drm_property_lookup_blob(crtc->dev, blob_id);
>  		if (new_blob == NULL)
>  			return -EINVAL;
> -		if (expected_size > 0 && expected_size != new_blob->length)
> +
> +		if (expected_size > 0 && expected_size != new_blob->length) {
> +			drm_property_unreference_blob(new_blob);
>  			return -EINVAL;
> +		}
>  	}
>  
>  	drm_atomic_replace_property_blob(blob, new_blob, replaced);
> +	drm_property_unreference_blob(new_blob);
>  
>  	return 0;
>  }
> -- 
> 2.10.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-10-26  7:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 19:46 [PATCH] drm: Release reference from blob lookup after replacing property Chris Wilson
2016-10-25 20:16 ` ✓ Fi.CI.BAT: success for " Patchwork
2016-10-25 21:27 ` [Intel-gfx] [PATCH] " Sean Paul
2016-10-25 21:45   ` Chris Wilson
2016-10-25 21:28 ` [PATCH v2] " Chris Wilson
2016-10-26  7:48   ` Ville Syrjälä [this message]
2016-10-26  8:29     ` Daniel Vetter
2016-10-25 21:46 ` ✗ Fi.CI.BAT: warning for drm: Release reference from blob lookup after replacing property (rev2) Patchwork

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=20161026074807.GU4617@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felix.monninger@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.