From: Wu Zhangjin <wuzhangjin@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Potential NULL pointer reference in platform_device_register()
Date: Thu, 10 Dec 2009 16:20:02 +0800 [thread overview]
Message-ID: <1260433202.7913.24.camel@falcon.domain.org> (raw)
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
next reply other threads:[~2009-12-10 8:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 8:20 Wu Zhangjin [this message]
2009-12-10 15:20 ` Greg KH
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=1260433202.7913.24.camel@falcon.domain.org \
--to=wuzhangjin@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome