diff mbox

drm/exynos: fix not to remain exynos_gem_obj as a leak

Message ID 1372645032-4219-1-git-send-email-sw0312.kim@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Seung-Woo Kim July 1, 2013, 2:17 a.m. UTC
From: YoungJun Cho <yj44.cho@samsung.com>

The exynos_drm_gem_create() only calls drm_gem_object_release()
when exynos_drm_alloc_buf() is failed, and exynos_gem_obj remains
as a leak, which is allocated in exynos_drm_gem_init().
So this patch fixes it not to remain as a leak.

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
This patch is based on exynos-drm-next branch.

 drivers/gpu/drm/exynos/exynos_drm_gem.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Inki Dae July 3, 2013, 2:47 a.m. UTC | #1
Applied.

Thanks,
Inki Dae

2013/7/1 Seung-Woo Kim <sw0312.kim@samsung.com>:
> From: YoungJun Cho <yj44.cho@samsung.com>
>
> The exynos_drm_gem_create() only calls drm_gem_object_release()
> when exynos_drm_alloc_buf() is failed, and exynos_gem_obj remains
> as a leak, which is allocated in exynos_drm_gem_init().
> So this patch fixes it not to remain as a leak.
>
> Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> This patch is based on exynos-drm-next branch.
>
>  drivers/gpu/drm/exynos/exynos_drm_gem.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index c3f15e7..24c22a8 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -246,13 +246,14 @@ struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
>         exynos_gem_obj->flags = flags;
>
>         ret = exynos_drm_alloc_buf(dev, buf, flags);
> -       if (ret < 0) {
> -               drm_gem_object_release(&exynos_gem_obj->base);
> -               goto err_fini_buf;
> -       }
> +       if (ret < 0)
> +               goto err_gem_fini;
>
>         return exynos_gem_obj;
>
> +err_gem_fini:
> +       drm_gem_object_release(&exynos_gem_obj->base);
> +       kfree(exynos_gem_obj);
>  err_fini_buf:
>         exynos_drm_fini_buf(dev, buf);
>         return ERR_PTR(ret);
> --
> 1.7.9.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index c3f15e7..24c22a8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -246,13 +246,14 @@  struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
 	exynos_gem_obj->flags = flags;
 
 	ret = exynos_drm_alloc_buf(dev, buf, flags);
-	if (ret < 0) {
-		drm_gem_object_release(&exynos_gem_obj->base);
-		goto err_fini_buf;
-	}
+	if (ret < 0)
+		goto err_gem_fini;
 
 	return exynos_gem_obj;
 
+err_gem_fini:
+	drm_gem_object_release(&exynos_gem_obj->base);
+	kfree(exynos_gem_obj);
 err_fini_buf:
 	exynos_drm_fini_buf(dev, buf);
 	return ERR_PTR(ret);