* [PATCH] drm: fb: cma: fix memory leak
@ 2016-06-12 15:03 Sudip Mukherjee
2016-06-13 7:52 ` Daniel Vetter
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2016-06-12 15:03 UTC (permalink / raw)
To: David Airlie, Daniel Vetter; +Cc: linux-kernel, dri-devel, Sudip Mukherjee
We may have a situation that the memory allocation for fbdefio fails
and then the allocation for fbops may succeed as some memory has been
freed somewhere. Lets free fbops also to face these rare situtation.
Since kfree can handle arguments as NULL, there should not be any
problem in calling both the kfree().
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
---
drivers/gpu/drm/drm_fb_cma_helper.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 2e7ef0b..c0b0c71 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -346,6 +346,7 @@ static int drm_fbdev_cma_defio_init(struct fb_info *fbi,
fbops = kzalloc(sizeof(*fbops), GFP_KERNEL);
if (!fbdefio || !fbops) {
kfree(fbdefio);
+ kfree(fbops);
return -ENOMEM;
}
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm: fb: cma: fix memory leak
2016-06-12 15:03 [PATCH] drm: fb: cma: fix memory leak Sudip Mukherjee
@ 2016-06-13 7:52 ` Daniel Vetter
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2016-06-13 7:52 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: David Airlie, Daniel Vetter, linux-kernel, dri-devel
On Sun, Jun 12, 2016 at 04:03:56PM +0100, Sudip Mukherjee wrote:
> We may have a situation that the memory allocation for fbdefio fails
> and then the allocation for fbops may succeed as some memory has been
> freed somewhere. Lets free fbops also to face these rare situtation.
> Since kfree can handle arguments as NULL, there should not be any
> problem in calling both the kfree().
>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Thanks for the patch, applied to drm-misc. For next time around please
figure out which patch created the broken using git blame. Then cite
that in your commit message and cc the author/reviewers of the broken
commit when submitting your fix.
-Daniel
> ---
> drivers/gpu/drm/drm_fb_cma_helper.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> index 2e7ef0b..c0b0c71 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -346,6 +346,7 @@ static int drm_fbdev_cma_defio_init(struct fb_info *fbi,
> fbops = kzalloc(sizeof(*fbops), GFP_KERNEL);
> if (!fbdefio || !fbops) {
> kfree(fbdefio);
> + kfree(fbops);
> return -ENOMEM;
> }
>
> --
> 1.9.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-13 7:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-12 15:03 [PATCH] drm: fb: cma: fix memory leak Sudip Mukherjee
2016-06-13 7:52 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome