mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference
@ 2013-05-16  9:31 Axel Lin
  2013-05-17 13:45 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2013-05-16  9:31 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: Rupesh Kumar, Michel JAOUEN, Loic Pallardy, David Woodhouse,
	linux-kernel

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference
  2013-05-16  9:31 [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference Axel Lin
@ 2013-05-17 13:45 ` Linus Walleij
  2013-06-07  0:26   ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2013-05-17 13:45 UTC (permalink / raw)
  To: Axel Lin
  Cc: Anton Vorontsov, Rupesh Kumar, Michel JAOUEN, Loic Pallardy,
	David Woodhouse, linux-kernel

On Thu, May 16, 2013 at 11:31 AM, Axel Lin <axel.lin@ingics.com> wrote:

> 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>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference
  2013-05-17 13:45 ` Linus Walleij
@ 2013-06-07  0:26   ` Anton Vorontsov
  0 siblings, 0 replies; 3+ messages in thread
From: Anton Vorontsov @ 2013-06-07  0:26 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Axel Lin, Rupesh Kumar, Michel JAOUEN, Loic Pallardy,
	David Woodhouse, linux-kernel

On Fri, May 17, 2013 at 03:45:55PM +0200, Linus Walleij wrote:
> On Thu, May 16, 2013 at 11:31 AM, Axel Lin <axel.lin@ingics.com> wrote:
> 
> > 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>
> 
> Acked-by: Linus Walleij <linus.walleij@linaro.org>

Applied, thanks!

Anton

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-07  0:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-16  9:31 [PATCH] power_supply: pm2301_charger: Fix NULL pointer dereference Axel Lin
2013-05-17 13:45 ` Linus Walleij
2013-06-07  0:26   ` Anton Vorontsov

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®