Skip to contentSkip to conversation

mbxfb_remove: fix null pointer dereference

PATCH In review Gaurav Singh 2 participants 2 messages Jul 26, 2020 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mbxfb_remove: fix null pointer dereference

Function mbxfb_debugfs_remove() accesses fbi->par without NULL check, hence do the NULL check in the caller mbxfb_remove().

---
 drivers/video/fbdev/mbx/mbxfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/mbx/mbxfb.c +1 -2
index 6dc287c819cb..515c0cda1994 100644
@@ -1012,11 +1012,10 @@ static int mbxfb_remove(struct platform_device *dev)
 
 	write_reg_dly(SYSRST_RST, SYSRST);
 
-	mbxfb_debugfs_remove(fbi);
-
 	if (fbi) {
 		struct mbxfb_info *mfbi = fbi->par;
 
+		mbxfb_debugfs_remove(fbi);
 		unregister_framebuffer(fbi);
 		if (mfbi) {
 			if (mfbi->platform_remove)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Gaurav Singh

Function mbxfb_debugfs_remove() accesses fbi->par without NULL check, hence do the NULL check in the caller mbxfb_remove().

...

drivers/video/fbdev/mbx/mbxfb.c static int mbxfb_remove(struct platform_device *dev) · line 1016

Quoted 8 lines
drivers/video/fbdev/mbx/mbxfb.c +0 -2
@@ -1012,11 +1012,10 @@ static int mbxfb_remove(struct platform_device *dev)
 
        write_reg_dly(SYSRST_RST, SYSRST);
 
-       mbxfb_debugfs_remove(fbi);
-
 
        if (fbi) {

Can you explain how this is NULL on ->remove()?

I bet this check is simply redundant. But you have to check and update commit message accordingly.

Quoted 6 lines
drivers/video/fbdev/mbx/mbxfb.c +1 -0
                struct mbxfb_info *mfbi = fbi->par;
 
+               mbxfb_debugfs_remove(fbi);
                unregister_framebuffer(fbi);
                if (mfbi) {
                        if (mfbi->platform_remove)
Signature · 2 lines
With Best Regards,
Andy Shevchenko