[patch] fb: handle NULL pointers in framebuffer release

Subsystems: framebuffer layer, the rest

STALE5240d

5 messages, 4 authors, 2012-05-29 · open the first message on its own page

[patch] fb: handle NULL pointers in framebuffer release

From: Dan Carpenter <hidden>
Date: 2012-05-14 20:58:37

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 <redacted>
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c..a55e366 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);
  */
 void framebuffer_release(struct fb_info *info)
 {
+	if (!info)
+		return;
 	kfree(info->apertures);
 	kfree(info);
 }

Re: [patch] fb: handle NULL pointers in framebuffer release

From: Marcin Slusarz <hidden>
Date: 2012-05-14 21:29:03

On Mon, May 14, 2012 at 11:58:37PM +0300, Dan Carpenter wrote:
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 <redacted>
Reviewed-by: Marcin Slusarz <redacted>
quoted hunk
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c..a55e366 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);
  */
 void framebuffer_release(struct fb_info *info)
 {
+	if (!info)
+		return;
 	kfree(info->apertures);
 	kfree(info);
 }

Re: [patch] fb: handle NULL pointers in framebuffer release

From: Hein Tibosch <hidden>
Date: 2012-05-15 07:20:14

On 5/15/2012 4:58 AM, Dan Carpenter wrote:
quoted hunk
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 <redacted>
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c..a55e366 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -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

Re: [patch] fb: handle NULL pointers in framebuffer release

From: Dan Carpenter <hidden>
Date: 2012-05-15 07:29:11

On Tue, May 15, 2012 at 03:20:14PM +0800, Hein Tibosch wrote:
On 5/15/2012 4:58 AM, Dan Carpenter wrote:
quoted
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 <redacted>
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c..a55e366 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -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);
+	}
Nah.  kfree() has a NULL check built in.  I think it would trigger
a checkpatch.pl warning?

regards,
dan carpenter

Re: [patch] fb: handle NULL pointers in framebuffer release

From: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Date: 2012-05-29 15:05:45

On 05/14/2012 08:58 PM, Dan Carpenter wrote:
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 <redacted>
Applied.


Thanks,

Florian Tobias Schandinat
quoted hunk
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c..a55e366 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);
  */
 void framebuffer_release(struct fb_info *info)
 {
+	if (!info)
+		return;
 	kfree(info->apertures);
 	kfree(info);
 }

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help