* Potential NULL pointer reference in platform_device_register()
@ 2009-12-10 8:20 Wu Zhangjin
2009-12-10 15:20 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Wu Zhangjin @ 2009-12-10 8:20 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel
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;
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.
Perhaps the above method will hide the real bug, so, what about BUG_ON(!
pdev).
Best Regards,
Wu Zhangjin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Potential NULL pointer reference in platform_device_register()
2009-12-10 8:20 Potential NULL pointer reference in platform_device_register() Wu Zhangjin
@ 2009-12-10 15:20 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2009-12-10 15:20 UTC (permalink / raw)
To: Wu Zhangjin; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-12-10 15:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-10 8:20 Potential NULL pointer reference in platform_device_register() Wu Zhangjin
2009-12-10 15:20 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox