video: fbdev: fbmem: fix pointer reference to null device field
Subsystems (3)
PATCH 1/1 video: fbdev: fbmem: fix pointer reference to null device field
In function do_remove_conflicting_framebuffers, if device is NULL, there will be null pointer reference. The patch add a check to the if expression.
---
Dear Linux folks
I discover this bug in the PowerPC VM provided by
Open source lab of Oregon State University:
https://lkml.org/lkml/2022/2/8/1145
I found that the root cause of null device field is in offb_init_fb:
info = framebuffer_alloc(sizeof(u32) * 16, NULL);
I have tested the patch in the PowerPC VM. Hope my patch can be correct.
Many Thanks
Zhouyi
--
drivers/video/fbdev/core/fbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/core/fbmem.c +1 -1
@@ -1579,7 +1579,7 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,* If it's not a platform device, at least print a warning. A * fix would add code to remove the device from the system. */ -if (dev_is_platform (device)) { +if (device &&dev_is_platform (device)) { registered_fb[i]->forced_out = true;platform_device_unregister (to_platform_device (device)); }else {
Signature · 1 line
2.25.1
Paul E. McKenney
maintainerQuoted 10 lines · Zhouyi Zhou
In function
do_remove_conflicting_framebuffers, if device is NULL, there will be null pointer reference. The patch add a check to the if expression.Signed-off-by Zhouyi Zhou <[email protected]>---
Dear Linux folksI discover this bug in the PowerPC VM provided by
Open source lab of Oregon State University:
Quoted 6 lines
https://lkml.org/lkml/2022/2/8/1145
I found that the root cause of null device field is in
offb_init_fb:
info =framebuffer_alloc(sizeof(u32) * 16, NULL);I have tested the patch in the PowerPC VM. Hope my patch can be correct.
This looks plausible to me, but I am quite unfamiliar with this code.
Thanx, Paul
Quoted 22 lines
Many Thanks
Zhouyi
--drivers/video/fbdev/core/fbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/video/fbdev/core/fbmem.c +1
-1@@ -1579,7 +1579,7 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,* If it's not a platform device, at least print a warning. A * fix would add code to remove the device from the system. */ -if (dev_is_platform (device)) { +if (device &&dev_is_platform (device)) { registered_fb[i]->forced_out = true;platform_device_unregister (to_platform_device (device)); }else {Signature · 1 line
2.25.1
Dear Zhouyi,
Am 10.02.22 um 07:58 schrieb Zhouyi Zhou:
Quoted 28 lines
In function
do_remove_conflicting_framebuffers, if device is NULL, there will be null pointer reference. The patch add a check to the if expression.Signed-off-by Zhouyi Zhou <[email protected]>---
Dear Linux folksI discover this bug in the PowerPC VM provided by
Open source lab of Oregon State University:https://lkml.org/lkml/2022/2/8/1145
I found that the root cause of null device field is in
offb_init_fb:
info =framebuffer_alloc(sizeof(u32) * 16, NULL);I have tested the patch in the PowerPC VM. Hope my patch can be correct.
Many Thanks
Zhouyi
--drivers/video/fbdev/core/fbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/video/fbdev/core/fbmem.c +0
-0
drivers/video/fbdev/core/fbmem.c static void do_remove_conflicting_framebuffers(struct apertures_struct *a, · line 1585
Quoted 8 lines
drivers/video/fbdev/core/fbmem.c +1
-1@@ -1579,7 +1579,7 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,* If it's not a platform device, at least print a warning. A * fix would add code to remove the device from the system. */ -if (dev_is_platform (device)) { +if (device &&dev_is_platform (device)) { registered_fb[i]->forced_out = true;platform_device_unregister (to_platform_device (device)); }else {
Looks reasonable.
Kind regards,
Paul
PS: Please note, this should be unrelated to my problem though, as I didn’t use linux-next. (Let’s continue in the other thread though.)