mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe()
@ 2025-12-03  3:55 Abdun Nihaal
  2025-12-05 10:32 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Abdun Nihaal @ 2025-12-03  3:55 UTC (permalink / raw)
  To: deller
  Cc: Abdun Nihaal, niederp, tomi.valkeinen, linux-fbdev, dri-devel,
	linux-kernel

The page allocated for vmem using __get_free_pages() is not freed on the
error paths after it. Fix that by adding a corresponding __free_pages()
call to the error path.

Fixes: facd94bc458a ("fbdev: ssd1307fb: Allocate page aligned video memory.")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
---
Compile tested only. Not tested on hardware.

v1->v2:
- Fix incorrect call to __free_pages with uninitialized values as
  pointed out by Helge Deller. Now, the patch uses vmem and vmem_size
  which hold valid values at the goto site.

  Thanks for catching. I'm sorry I overlooked this in v1.

v1 link: https://lore.kernel.org/all/20251202191225.111661-1-nihaal@cse.iitm.ac.in/

 drivers/video/fbdev/ssd1307fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index aa6cc0a8151a..83dd31fa1fab 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -680,7 +680,7 @@ static int ssd1307fb_probe(struct i2c_client *client)
 	if (!ssd1307fb_defio) {
 		dev_err(dev, "Couldn't allocate deferred io.\n");
 		ret = -ENOMEM;
-		goto fb_alloc_error;
+		goto fb_defio_error;
 	}
 
 	ssd1307fb_defio->delay = HZ / refreshrate;
@@ -757,6 +757,8 @@ static int ssd1307fb_probe(struct i2c_client *client)
 		regulator_disable(par->vbat_reg);
 reset_oled_error:
 	fb_deferred_io_cleanup(info);
+fb_defio_error:
+	__free_pages(vmem, get_order(vmem_size));
 fb_alloc_error:
 	framebuffer_release(info);
 	return ret;
-- 
2.43.0


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

* Re: [PATCH v2] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe()
  2025-12-03  3:55 [PATCH v2] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe() Abdun Nihaal
@ 2025-12-05 10:32 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2025-12-05 10:32 UTC (permalink / raw)
  To: Abdun Nihaal
  Cc: niederp, tomi.valkeinen, linux-fbdev, dri-devel, linux-kernel

On 12/3/25 04:55, Abdun Nihaal wrote:
> The page allocated for vmem using __get_free_pages() is not freed on the
> error paths after it. Fix that by adding a corresponding __free_pages()
> call to the error path.
> 
> Fixes: facd94bc458a ("fbdev: ssd1307fb: Allocate page aligned video memory.")
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
> ---
> Compile tested only. Not tested on hardware.
> 
> v1->v2:
> - Fix incorrect call to __free_pages with uninitialized values as
>    pointed out by Helge Deller. Now, the patch uses vmem and vmem_size
>    which hold valid values at the goto site.
> 
>    Thanks for catching. I'm sorry I overlooked this in v1.
> 
> v1 link: https://lore.kernel.org/all/20251202191225.111661-1-nihaal@cse.iitm.ac.in/
> 
>   drivers/video/fbdev/ssd1307fb.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
applied.

Thanks!
Helge

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

end of thread, other threads:[~2025-12-05 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03  3:55 [PATCH v2] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe() Abdun Nihaal
2025-12-05 10:32 ` Helge Deller

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

all inboxes | Powered by JetHome®