Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240612 > unrolled thread
| Started by | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| First post | 2015-10-06 17:50 +0200 |
| Last post | 2015-10-08 14:50 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2] drm/gma500: fix double freeing Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-10-06 17:50 +0200
Re: [PATCH v2] drm/gma500: fix double freeing Patrik Jakobsson <patrik.r.jakobsson@gmail.com> - 2015-10-07 23:00 +0200
[PATCH v3] drm/gma500: fix double freeing Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-10-08 14:50 +0200
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-10-06 17:50 +0200 |
| Subject | [PATCH v2] drm/gma500: fix double freeing |
| Message-ID | <qgCF5-20n-29@gated-at.bofh.it> |
We are allocating backing using psbfb_alloc() and so
backing->stolen is always true. So we were freeing backing two times.
Moreover if we follow the execution path then we should be freeing
backing after we have released the helper. So remove the one which frees
backing before the helper is released.
While at it the error labels are also renamed to give a meaningful
name.
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
Hi Patrik,
If you donot like the labels I will change them according to what you
have suggested.
drivers/gpu/drm/gma500/framebuffer.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..52e2bf3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -411,7 +411,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
- goto out_err1;
+ goto err_alloc_fbi;
}
info->par = fbdev;
@@ -419,7 +419,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
if (ret)
- goto out_unref;
+ goto err_framebuffer_init;
fb = &psbfb->base;
psbfb->fbdev = info;
@@ -465,14 +465,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,
mutex_unlock(&dev->struct_mutex);
return 0;
-out_unref:
- if (backing->stolen)
- psb_gtt_free_range(dev, backing);
- else
- drm_gem_object_unreference(&backing->gem);
-
+err_framebuffer_init:
drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
-out_err1:
+err_alloc_fbi:
mutex_unlock(&dev->struct_mutex);
psb_gtt_free_range(dev, backing);
return ret;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Patrik Jakobsson <patrik.r.jakobsson@gmail.com> |
|---|---|
| Date | 2015-10-07 23:00 +0200 |
| Message-ID | <qh3YC-7Gv-3@gated-at.bofh.it> |
| In reply to | #1240612 |
On Tue, Oct 6, 2015 at 5:48 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> We are allocating backing using psbfb_alloc() and so
> backing->stolen is always true. So we were freeing backing two times.
> Moreover if we follow the execution path then we should be freeing
> backing after we have released the helper. So remove the one which frees
> backing before the helper is released.
> While at it the error labels are also renamed to give a meaningful
> name.
>
> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> Hi Patrik,
> If you donot like the labels I will change them according to what you
> have suggested.
Hi
Label names are used in all sorts of funny ways in the kernel. However
CodingStyle is quite clear on the matter: "Also don't name them after
the goto location like "err_kmalloc_failed:" and if you think about
it, it makes sense. Let's say we add another goto to that label then
the name wouldn't be correct anymore.
err_release and err_unlock would make me happier :)
With that fixed
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Thanks
> drivers/gpu/drm/gma500/framebuffer.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
> index 2eaf1b3..52e2bf3 100644
> --- a/drivers/gpu/drm/gma500/framebuffer.c
> +++ b/drivers/gpu/drm/gma500/framebuffer.c
> @@ -411,7 +411,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
> info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper);
> if (IS_ERR(info)) {
> ret = PTR_ERR(info);
> - goto out_err1;
> + goto err_alloc_fbi;
> }
> info->par = fbdev;
>
> @@ -419,7 +419,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
>
> ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
> if (ret)
> - goto out_unref;
> + goto err_framebuffer_init;
>
> fb = &psbfb->base;
> psbfb->fbdev = info;
> @@ -465,14 +465,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,
>
> mutex_unlock(&dev->struct_mutex);
> return 0;
> -out_unref:
> - if (backing->stolen)
> - psb_gtt_free_range(dev, backing);
> - else
> - drm_gem_object_unreference(&backing->gem);
> -
> +err_framebuffer_init:
> drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
> -out_err1:
> +err_alloc_fbi:
> mutex_unlock(&dev->struct_mutex);
> psb_gtt_free_range(dev, backing);
> return ret;
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-10-08 14:50 +0200 |
| Subject | [PATCH v3] drm/gma500: fix double freeing |
| Message-ID | <qhiNX-3NW-1@gated-at.bofh.it> |
| In reply to | #1240612 |
We are allocating backing using psbfb_alloc() and so
backing->stolen is always true. So we were freeing backing two times.
Moreover if we follow the execution path then we should be freeing
backing after we have released the helper. So remove the one which frees
backing before the helper is released.
While at it the error labels are also renamed to give a meaningful
name.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
---
drivers/gpu/drm/gma500/framebuffer.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 2eaf1b3..52e2bf3 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -411,7 +411,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper);
if (IS_ERR(info)) {
ret = PTR_ERR(info);
- goto out_err1;
+ goto err_unlock;
}
info->par = fbdev;
@@ -419,7 +419,7 @@ static int psbfb_create(struct psb_fbdev *fbdev,
ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
if (ret)
- goto out_unref;
+ goto err_release;
fb = &psbfb->base;
psbfb->fbdev = info;
@@ -465,14 +465,9 @@ static int psbfb_create(struct psb_fbdev *fbdev,
mutex_unlock(&dev->struct_mutex);
return 0;
-out_unref:
- if (backing->stolen)
- psb_gtt_free_range(dev, backing);
- else
- drm_gem_object_unreference(&backing->gem);
-
+err_release:
drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
-out_err1:
+err_unlock:
mutex_unlock(&dev->struct_mutex);
psb_gtt_free_range(dev, backing);
return ret;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web