* [PATCH] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
@ 2019-09-30 3:09 Navid Emamdoost
2019-10-01 13:34 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-09-30 3:09 UTC (permalink / raw)
Cc: Jan Sebastian Götte, devel, linux-fbdev, Nishad Kamdar,
Greg Kroah-Hartman, kjlu, linux-kernel, dri-devel, Daniel Vetter,
emamd001, Bhanusree Pola, smccaman, Phil Reid, Sam Ravnborg,
Navid Emamdoost
In fbtft_framebuffer_alloc the error handling path should take care of
releasing frame buffer after it is allocated via framebuffer_alloc, too.
Therefore, in two failure cases the goto destination is changed to
address this issue.
Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/staging/fbtft/fbtft-core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index cf5700a2ea66..a0a67aa517f0 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -714,7 +714,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
if (par->gamma.curves && gamma) {
if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma,
strlen(gamma)))
- goto alloc_fail;
+ goto release_framebuf;
}
/* Transmit buffer */
@@ -731,7 +731,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
if (txbuflen > 0) {
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
if (!txbuf)
- goto alloc_fail;
+ goto release_framebuf;
par->txbuf.buf = txbuf;
par->txbuf.len = txbuflen;
}
@@ -753,6 +753,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
return info;
+release_framebuf:
+ framebuffer_release(info);
+
alloc_fail:
vfree(vmem);
--
2.17.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc
2019-09-30 3:09 [PATCH] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc Navid Emamdoost
@ 2019-10-01 13:34 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2019-10-01 13:34 UTC (permalink / raw)
To: Navid Emamdoost
Cc: Jan Sebastian Götte, devel, linux-fbdev, Nishad Kamdar,
Greg Kroah-Hartman, smccaman, kjlu, linux-kernel, dri-devel,
emamd001, Bhanusree Pola, Daniel Vetter, Phil Reid, Sam Ravnborg
On Sun, Sep 29, 2019 at 10:09:45PM -0500, Navid Emamdoost wrote:
> In fbtft_framebuffer_alloc the error handling path should take care of
> releasing frame buffer after it is allocated via framebuffer_alloc, too.
> Therefore, in two failure cases the goto destination is changed to
> address this issue.
>
> Fixes: c296d5f9957c ("staging: fbtft: core support")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Looks good.
Reviewed-by: Dan Carpenter <dan.carpenter@gmail.com>
regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-01 13:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 3:09 [PATCH] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc Navid Emamdoost
2019-10-01 13:34 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).