[Spice-devel,02/11] Do not leak memory if qxl_release_list_add fails

Submitted by Frediano Ziglio on May 27, 2015, 10:03 a.m.

Details

Message ID 1432721046-4418-3-git-send-email-fziglio@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Frediano Ziglio May 27, 2015, 10:03 a.m.
If the function fails reference counter to the object is not decremented
causing leaks.
This is hard to spot as it happens only on very low memory situations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 qxl/qxl_ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/qxl/qxl_ioctl.c b/qxl/qxl_ioctl.c
index afd7297..e8b5207 100644
--- a/qxl/qxl_ioctl.c
+++ b/qxl/qxl_ioctl.c
@@ -122,8 +122,10 @@  static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev,
 	qobj = gem_to_qxl_bo(gobj);
 
 	ret = qxl_release_list_add(release, qobj);
-	if (ret)
+	if (ret) {
+		drm_gem_object_unreference_unlocked(gobj);
 		return NULL;
+	}
 
 	return qobj;
 }

Comments

On 27 May 2015 at 20:03, Frediano Ziglio <fziglio@redhat.com> wrote:
> If the function fails reference counter to the object is not decremented
> causing leaks.
> This is hard to spot as it happens only on very low memory situations.
>
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>

Looks good,

Reviewed-by: Dave Airlie <airlied@redhat.com>

Dave.