Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH v2 1/1] staging: fbtft: core: fix potential memory leak in fbtft_probe_common()
@ 2025-11-12 19:22 Andy Shevchenko
  2025-11-13  8:21 ` Abdun Nihaal
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2025-11-12 19:22 UTC (permalink / raw)
  To: Abdun Nihaal, dri-devel, linux-fbdev, linux-staging, linux-kernel
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Jianglei Nie,
	Andy Shevchenko

From: Jianglei Nie <niejianglei2021@163.com>

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: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

v2: fixed in accordance with Andy's review

 drivers/staging/fbtft/fbtft-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 9e7b84071174..8a5ccc8ae0a1 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -1171,8 +1171,8 @@ int fbtft_probe_common(struct fbtft_display *display,
 	par->pdev = pdev;
 
 	if (display->buswidth == 0) {
-		dev_err(dev, "buswidth is not set\n");
-		return -EINVAL;
+		ret = dev_err_probe(dev, -EINVAL, "buswidth is not set\n");
+		goto out_release;
 	}
 
 	/* write register functions */
-- 
2.50.1


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

* Re: [PATCH v2 1/1] staging: fbtft: core: fix potential memory leak in fbtft_probe_common()
  2025-11-12 19:22 [PATCH v2 1/1] staging: fbtft: core: fix potential memory leak in fbtft_probe_common() Andy Shevchenko
@ 2025-11-13  8:21 ` Abdun Nihaal
  0 siblings, 0 replies; 2+ messages in thread
From: Abdun Nihaal @ 2025-11-13  8:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel,
	Andy Shevchenko, Greg Kroah-Hartman, Jianglei Nie

Looks good to me.
Acked-by: Abdun Nihaal <abdun.nihaal@gmail.com>

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

end of thread, other threads:[~2025-11-13  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 19:22 [PATCH v2 1/1] staging: fbtft: core: fix potential memory leak in fbtft_probe_common() Andy Shevchenko
2025-11-13  8:21 ` Abdun Nihaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox