fb: handle NULL pointers in framebuffer release
Subsystems (2)
PATCH 1/1 fb: handle NULL pointers in framebuffer release
This function is called with a potential NULL pointer in picolcd_init_framebuffer() and it causes a static checker warning. This used to handle NULL pointers when the picolcd code was written, but a couple months later we added the "info->apertures" dereference.
drivers/video/fbsysfs.c +2 -0
@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);*/ void framebuffer_release (struct fb_info *info) { +if (!info) +return ;kfree (info->apertures);kfree (info); }
Quoted 6 lines · Dan Carpenter
This function is called with a potential NULL pointer in
picolcd_init_framebuffer()and it causes a static checker warning. This used to handle NULL pointers when the picolcd code was written, but a couple months later we added the "info->apertures" dereference.Signed-off-by Dan Carpenter <[email protected]>
Quoted 13 lines
drivers/video/fbsysfs.c +2
-0@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);*/ void framebuffer_release (struct fb_info *info) { +if (!info) +return ;kfree (info->apertures);kfree (info); }
Quoted 12 lines · Dan Carpenter
This function is called with a potential NULL pointer in
picolcd_init_framebuffer()and it causes a static checker warning. This used to handle NULL pointers when the picolcd code was written, but a couple months later we added the "info->apertures" dereference.Signed-off-by Dan Carpenter <[email protected]>drivers/video/fbsysfs.c +0
-0
drivers/video/fbsysfs.c EXPORT_SYMBOL(framebuffer_alloc); · line 87
Quoted 8 lines
drivers/video/fbsysfs.c +2
-0@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);*/ void framebuffer_release (struct fb_info *info) { +if (!info) +return ;kfree (info->apertures);kfree (info); }
And not like this:
+ if (info) {
+ if (info->apertures)
+ kfree(info->apertures);
+ kfree(info);
+ }
?
- Hein
Quoted 24 lines · Hein Tibosch
Quoted 12 lines · Dan Carpenter
This function is called with a potential NULL pointer in
picolcd_init_framebuffer()and it causes a static checker warning. This used to handle NULL pointers when the picolcd code was written, but a couple months later we added the "info->apertures" dereference.Signed-off-by Dan Carpenter <[email protected]>drivers/video/fbsysfs.c +0
-0drivers/video/fbsysfs.c EXPORT_SYMBOL(framebuffer_alloc); · line 87
Quoted 8 lines
drivers/video/fbsysfs.c +2
-0@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);*/ void framebuffer_release (struct fb_info *info) { +if (!info) +return ;kfree (info->apertures);kfree (info); }And not like this:
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (info) { + if (info->apertures) + kfree(info->apertures); + kfree(info); + }
Nah. kfree() has a NULL check built in. I think it would trigger a checkpatch.pl warning?
regards,
dan carpenter
Florian Tobias Schandinat
AppliedQuoted 6 lines · Dan Carpenter
This function is called with a potential NULL pointer in
picolcd_init_framebuffer()and it causes a static checker warning. This used to handle NULL pointers when the picolcd code was written, but a couple months later we added the "info->apertures" dereference.Signed-off-by Dan Carpenter <[email protected]>
Applied.
Thanks,
Florian Tobias Schandinat
Quoted 15 lines
drivers/video/fbsysfs.c +2
-0@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);*/ void framebuffer_release (struct fb_info *info) { +if (!info) +return ;kfree (info->apertures);kfree (info); }