linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: core: fix potential memory leak in fbtft_probe_common()
@ 2022-09-28  6:23 Jianglei Nie
  2024-04-04 16:35 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Jianglei Nie @ 2022-09-28  6:23 UTC (permalink / raw)
  To: gregkh, tzimmermann, andriy.shevchenko, javierm, sam, steve,
	noralf, u.kleine-koenig
  Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel, Jianglei Nie

fbtft_probe_common() allocates a memory chunk for "info" with
fbtft_framebuffer_alloc(). When "display->buswidth == 0" is true, the
function returns without releasing the "info", which will lead to a
memory leak.

Fix it by calling fbtft_framebuffer_release() when "display->buswidth
== 0" is true.

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
---
 drivers/staging/fbtft/fbtft-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index afaba94d1d1c..ecf595aff786 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1225,6 +1225,7 @@ int fbtft_probe_common(struct fbtft_display *display,
 
 	if (display->buswidth == 0) {
 		dev_err(dev, "buswidth is not set\n");
+		fbtft_framebuffer_release(info);
 		return -EINVAL;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: fbtft: core: fix potential memory leak in fbtft_probe_common()
  2022-09-28  6:23 [PATCH] staging: fbtft: core: fix potential memory leak in fbtft_probe_common() Jianglei Nie
@ 2024-04-04 16:35 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2024-04-04 16:35 UTC (permalink / raw)
  To: Jianglei Nie
  Cc: gregkh, tzimmermann, javierm, sam, steve, noralf,
	u.kleine-koenig, dri-devel, linux-fbdev, linux-staging,
	linux-kernel

On Wed, Sep 28, 2022 at 02:23:01PM +0800, Jianglei Nie wrote:
> fbtft_probe_common() allocates a memory chunk for "info" with
> fbtft_framebuffer_alloc(). When "display->buswidth == 0" is true, the
> function returns without releasing the "info", which will lead to a
> memory leak.
> 
> Fix it by calling fbtft_framebuffer_release() when "display->buswidth
> == 0" is true.

Fixes tag?

...

>  	if (display->buswidth == 0) {
>  		dev_err(dev, "buswidth is not set\n");
> +		fbtft_framebuffer_release(info);
>  		return -EINVAL;

		ret = dev_err_probe(dev, -EINVAL, "buswidth is not set\n");
		goto out_release;

>  	}

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-04 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28  6:23 [PATCH] staging: fbtft: core: fix potential memory leak in fbtft_probe_common() Jianglei Nie
2024-04-04 16:35 ` Andy Shevchenko

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).