Re: [PATCH] POWER: gpio-charger: Check result of kzalloc

From: Anton Vorontsov
Date: Tue Dec 21 2010 - 19:03:45 EST


On Thu, Nov 18, 2010 at 11:08:37PM +0100, Lars-Peter Clausen wrote:
> Since kzalloc can return NULL we have to check its result.
>
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> ---

Lars, Vasiliy, Dan,

Thanks for the patch! I applied the following:

commit 2e9ff5f5e4c6b034554f3539f29529265279102c
Author: Lars-Peter Clausen <lars@xxxxxxxxxx>
Date: Thu Nov 18 23:08:37 2010 +0100

gpio-charger: Check result of kzalloc

Since kzalloc can return NULL we have to check its result.

Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
Signed-off-by: Vasiliy Kulikov <segoon@xxxxxxxxxxxx>
Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
Signed-off-by: Anton Vorontsov <cbouatmailru@xxxxxxxxx>

diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index fccbe99..8458caf 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;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/