Skip to contentSkip to conversation

fbdev: clps711x-fb: unregister fb when clps711x_fb_probe register failed

PATCH In review clingfei 2 participants 2 messages Oct 3, 2024 Framebuffer layer

lore
Share & tools
lore

clingfei

author
#0 lore raw

PATCH 1/1 fbdev: clps711x-fb: unregister fb when clps711x_fb_probe register failed

When register_framebuffer failed, it jumps out_fb_dealloc_cmap without calling unregister_framebuffer, which may cause potential memory leak.

---
 drivers/video/fbdev/clps711x-fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/clps711x-fb.c +2 -1
index 9e3df1df5ac4..69db40a7a361 100644
@@ -328,10 +328,11 @@ static int clps711x_fb_probe(struct platform_device *pdev)
 
 	ret = register_framebuffer(info);
 	if (ret)
-		goto out_fb_dealloc_cmap;
+		goto out_fb_unregister;
 
 	return 0;
 
+out_fb_unregister:
 	unregister_framebuffer(info);
 
 out_fb_dealloc_cmap:
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · clingfei

When register_framebuffer failed, it jumps out_fb_dealloc_cmap without calling unregister_framebuffer, which may cause potential memory leak.

This looks completely wrong. If register_framebuffer() fails, then the work that register_framebuffer() does internally should be cleaned up and unregister_framebuffer() should not be necessary.

The code looks correct as-is to me, so there's no need to patch it. If there is a memory leak, that'll be in register_framebuffer() itself.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!