public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: gpio-charger: fix potential NULL dereference
@ 2010-11-19 18:41 Vasiliy Kulikov
  2010-11-19 19:01 ` Lars-Peter Clausen
  2010-11-26 17:06 ` Vasiliy Kulikov
  0 siblings, 2 replies; 3+ messages in thread
From: Vasiliy Kulikov @ 2010-11-19 18:41 UTC (permalink / raw)
  To: kernel-janitors; +Cc: Lars-Peter Clausen, Anton Vorontsov, linux-kernel

kzalloc() result is not compared with NULL.  It might lead to NULL
pointer dereference in OOM situation.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Compile tested only.

 drivers/power/gpio-charger.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index fccbe99..b07a71c 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -87,6 +87,10 @@ static int __devinit gpio_charger_probe(struct platform_device *pdev)
 	}
 
 	gpio_charger = kzalloc(sizeof(*gpio_charger), GFP_KERNEL);
+	if (!gpio_charger) {
+		dev_err(&pdev->dev, "kzalloc failed\n");
+		return -ENOMEM;
+	}
 
 	charger = &gpio_charger->charger;
 
-- 
1.7.0.4


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

end of thread, other threads:[~2010-11-26 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19 18:41 [PATCH] power: gpio-charger: fix potential NULL dereference Vasiliy Kulikov
2010-11-19 19:01 ` Lars-Peter Clausen
2010-11-26 17:06 ` Vasiliy Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox