Commit 426a724c authored by Felix Monninger's avatar Felix Monninger Committed by Greg Kroah-Hartman

drm: Release reference from blob lookup after replacing property

commit cac5fced upstream.

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: default avatarFelix Monninger <felix.monninger@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98420Signed-off-by: default avatarFelix Monninger <felix.monninger@gmail.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Fixes: 5488dc16 ("drm: introduce pipe color correction properties")
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161025212808.3908-1-chris@chris-wilson.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5064a6a0
...@@ -420,18 +420,21 @@ drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc, ...@@ -420,18 +420,21 @@ drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc,
ssize_t expected_size, ssize_t expected_size,
bool *replaced) bool *replaced)
{ {
struct drm_device *dev = crtc->dev;
struct drm_property_blob *new_blob = NULL; struct drm_property_blob *new_blob = NULL;
if (blob_id != 0) { 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) if (new_blob == NULL)
return -EINVAL; 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; return -EINVAL;
}
} }
drm_atomic_replace_property_blob(blob, new_blob, replaced); drm_atomic_replace_property_blob(blob, new_blob, replaced);
drm_property_unreference_blob(new_blob);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment