public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 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

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