From 2e9ff5f5e4c6b034554f3539f29529265279102c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 18 Nov 2010 23:08:37 +0100 Subject: [PATCH] gpio-charger: Check result of kzalloc Since kzalloc can return NULL we have to check its result. Signed-off-by: Lars-Peter Clausen Signed-off-by: Vasiliy Kulikov Signed-off-by: Dan Carpenter Signed-off-by: Anton Vorontsov --- drivers/power/gpio-charger.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c index fccbe99b619c..8458cafcd2b2 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, "Failed to alloc driver structure\n"); + return -ENOMEM; + } charger = &gpio_charger->charger; -- 2.20.1