public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Potential NULL pointer reference in platform_device_register()
Date: Thu, 10 Dec 2009 07:20:54 -0800	[thread overview]
Message-ID: <20091210152054.GA11913@suse.de> (raw)
In-Reply-To: <1260433202.7913.24.camel@falcon.domain.org>

On Thu, Dec 10, 2009 at 04:20:02PM +0800, Wu Zhangjin wrote:
> Hi, Greg KH,
> 
> Should we filter the potential NULL pointer in
> platform_device_register() like this?
> 
> drivers/base/platform.c:
> 
> int platform_device_register(struct platform_device *pdev)
> {
> +	 if (!pdev)
> +                return -EINVAL;

Why, who is calling this function with a NULL pointer?

> 
>         device_initialize(&pdev->dev);
>         return platform_device_add(pdev);
> }
> EXPORT_SYMBOL_GPL(platform_device_register);
> 
> Of course, the developers need to ensure they not register a NULL
> platform device, but sometimes they will not know that.

Why would you never know that?

> Perhaps the above method will hide the real bug, so, what about BUG_ON(!
> pdev).

That is what happens today anyway if you pass a NULL pointer in :)

thanks,

greg k-h

      reply	other threads:[~2009-12-10 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-10  8:20 Potential NULL pointer reference in platform_device_register() Wu Zhangjin
2009-12-10 15:20 ` Greg KH [this message]

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=20091210152054.GA11913@suse.de \
    --to=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wuzhangjin@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox