All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-fbdev@vger.kernel.org
Subject: Re: [patch] fb: handle NULL pointers in framebuffer release
Date: Tue, 15 May 2012 07:29:11 +0000	[thread overview]
Message-ID: <20120515072911.GF16999@mwanda> (raw)
In-Reply-To: <20120514205837.GE20836@elgon.mountain>

On Tue, May 15, 2012 at 03:20:14PM +0800, Hein Tibosch wrote:
> On 5/15/2012 4:58 AM, 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 <dan.carpenter@oracle.com>
> >
> > 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


  parent reply	other threads:[~2012-05-15  7:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-14 20:58 [patch] fb: handle NULL pointers in framebuffer release Dan Carpenter
2012-05-14 21:29 ` Marcin Slusarz
2012-05-15  7:20 ` Hein Tibosch
2012-05-15  7:29 ` Dan Carpenter [this message]
2012-05-29 15:05 ` Florian Tobias Schandinat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120515072911.GF16999@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-fbdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.