* [PATCH 1/1] taging: fbtft: fix memory leak
@ 2018-04-03 13:33 Xidong Wang
2018-04-03 16:20 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Xidong Wang @ 2018-04-03 13:33 UTC (permalink / raw)
To: Xidong Wang, Thomas Petazzoni, Greg Kroah-Hartman, devel, linux-kernel
Cc: stable, Xidong Wang
From: Xidong Wang <2711406067@qq.com>
In function fbtft_framebuffer_alloc(), the memory allocated by
framebuffer_alloc() is not released on the error path that txbuflen > 0
and txbuf, which holds the return value of devm_kzalloc(), is NULL.
This will result in a memory leak bug.
Signed-off-by: Xidong Wang <2711406067@qq.com>
---
drivers/staging/fbtft/fbtft-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 0e36b66..e92771e 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -836,7 +836,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 err_info;
par->txbuf.buf = txbuf;
par->txbuf.len = txbuflen;
}
@@ -872,6 +872,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
return info;
+err_info:
+ framebuffer_release(info);
+
alloc_fail:
vfree(vmem);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] taging: fbtft: fix memory leak
2018-04-03 13:33 [PATCH 1/1] taging: fbtft: fix memory leak Xidong Wang
@ 2018-04-03 16:20 ` Joe Perches
0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2018-04-03 16:20 UTC (permalink / raw)
To: Xidong Wang, Thomas Petazzoni, Greg Kroah-Hartman, devel, linux-kernel
Cc: stable, Xidong Wang
On Tue, 2018-04-03 at 21:33 +0800, Xidong Wang wrote:
> From: Xidong Wang <2711406067@qq.com>
>
> In function fbtft_framebuffer_alloc(), the memory allocated by
> framebuffer_alloc() is not released on the error path that txbuflen > 0
> and txbuf, which holds the return value of devm_kzalloc(), is NULL.
> This will result in a memory leak bug.
[]
> diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
[]
> @@ -836,7 +836,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 err_info;
> par->txbuf.buf = txbuf;
> par->txbuf.len = txbuflen;
> }
> @@ -872,6 +872,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
>
> return info;
>
> +err_info:
> + framebuffer_release(info);
> +
> alloc_fail:
> vfree(vmem);
What about the
if (par->gamma.curves && gamma) {
if (fbtft_gamma_parse_str(par,
par->gamma.curves, gamma, strlen(gamma)))
goto alloc_fail;
}
a little above this?
Presumable then it should goto err_info too.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] taging: fbtft: fix memory leak
2018-04-03 13:14 Xidong Wang
2018-04-03 13:29 ` Greg Kroah-Hartman
@ 2018-04-03 13:52 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-04-03 13:52 UTC (permalink / raw)
To: Xidong Wang
Cc: Thomas Petazzoni, Greg Kroah-Hartman, devel, linux-kernel,
Xidong Wang, stable
There is a typo in the subject. It should be "Staging" instead of
"taging:".
On Tue, Apr 03, 2018 at 09:14:28PM +0800, Xidong Wang wrote:
> From: Xidong Wang <2711406067@qq.com>
>
> In function fbtft_framebuffer_alloc(), the memory allocated by
> framebuffer_alloc() is not released on the error path that txbuflen > 0
> and txbuf, which holds the return value of devm_kzalloc(), is NULL.
> This will result in a memory leak bug.
The txbuf chunk seems to have been dropped. You're right that it needs
to be fixed as well.
if (txbuflen > 0) {
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
if (!txbuf)
- goto alloc_fail;
+ goto err_info;
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] taging: fbtft: fix memory leak
2018-04-03 13:14 Xidong Wang
@ 2018-04-03 13:29 ` Greg Kroah-Hartman
2018-04-03 13:52 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2018-04-03 13:29 UTC (permalink / raw)
To: Xidong Wang; +Cc: Thomas Petazzoni, devel, linux-kernel, stable, Xidong Wang
On Tue, Apr 03, 2018 at 09:14:28PM +0800, Xidong Wang wrote:
> From: Xidong Wang <2711406067@qq.com>
>
> In function fbtft_framebuffer_alloc(), the memory allocated by
> framebuffer_alloc() is not released on the error path that txbuflen > 0
> and txbuf, which holds the return value of devm_kzalloc(), is NULL.
> This will result in a memory leak bug.
>
> Signed-off-by: Xidong Wang <2711406067@qq.com>
> ---
> drivers/staging/fbtft/fbtft-core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] taging: fbtft: fix memory leak
@ 2018-04-03 13:14 Xidong Wang
2018-04-03 13:29 ` Greg Kroah-Hartman
2018-04-03 13:52 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Xidong Wang @ 2018-04-03 13:14 UTC (permalink / raw)
To: Xidong Wang, Thomas Petazzoni, Greg Kroah-Hartman, devel, linux-kernel
Cc: stable, Xidong Wang
From: Xidong Wang <2711406067@qq.com>
In function fbtft_framebuffer_alloc(), the memory allocated by
framebuffer_alloc() is not released on the error path that txbuflen > 0
and txbuf, which holds the return value of devm_kzalloc(), is NULL.
This will result in a memory leak bug.
Signed-off-by: Xidong Wang <2711406067@qq.com>
---
drivers/staging/fbtft/fbtft-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 0e36b66..169e9dc 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -819,7 +819,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 err_info;
}
/* Transmit buffer */
@@ -872,6 +872,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
return info;
+err_info:
+ framebuffer_release(info);
+
alloc_fail:
vfree(vmem);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-04-03 16:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-03 13:33 [PATCH 1/1] taging: fbtft: fix memory leak Xidong Wang
2018-04-03 16:20 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2018-04-03 13:14 Xidong Wang
2018-04-03 13:29 ` Greg Kroah-Hartman
2018-04-03 13:52 ` 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).