From: Axel Lin <axel.lin@ingics.com>
To: Anton Vorontsov <cbou@mail.ru>
Cc: Rupesh Kumar <rupesh.kumar@stericsson.com>,
Michel JAOUEN <michel.jaouen@stericsson.com>,
Loic Pallardy <loic.pallardy@stericsson.com>,
David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference
Date: Thu, 16 May 2013 17:31:00 +0800 [thread overview]
Message-ID: <1368696660.8439.1.camel@phoenix> (raw)
Add checking pl_data in probe, this prevent possible NULL pointer dereference.
Also fix NULL pointer deference in dev_err when allocate memory for pm2 fails.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/power/pm2301_charger.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index a441751..c972389 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -1007,9 +1007,14 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
u8 val;
int i;
+ if (!pl_data) {
+ dev_err(&i2c_client->dev, "No platform data supplied\n");
+ return -EINVAL;
+ }
+
pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
if (!pm2) {
- dev_err(pm2->dev, "pm2xxx_charger allocation failed\n");
+ dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n");
return -ENOMEM;
}
--
1.8.1.2
next reply other threads:[~2013-05-16 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 9:31 Axel Lin [this message]
2013-05-17 13:45 ` Linus Walleij
2013-06-07 0:26 ` Anton Vorontsov
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=1368696660.8439.1.camel@phoenix \
--to=axel.lin@ingics.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loic.pallardy@stericsson.com \
--cc=michel.jaouen@stericsson.com \
--cc=rupesh.kumar@stericsson.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
all inboxes | Powered by JetHome®