lkml.org 
[lkml]   [2009]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Potential NULL pointer reference in platform_device_register()
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


\
 
 \ /
  Last update: 2009-12-10 16:27    [W:0.070 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site