gpio-sta2x11: Fix potential NULL pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Wed, 12 Jun 2013 04:02:45 +0000 (09:32 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 17 Jun 2013 08:26:34 +0000 (10:26 +0200)
devm_kzalloc can return NULL. Check for it before dereferencing.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-sta2x11.c

index 558542552aae4a51590ff5e789c3db7ccb34ad89..9b5564564bcd73c55a6cd8094073f2c0b8226603 100644 (file)
@@ -371,6 +371,8 @@ static int gsta_probe(struct platform_device *dev)
        res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 
        chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL);
+       if (!chip)
+               return -ENOMEM;
        chip->dev = &dev->dev;
        chip->reg_base = devm_request_and_ioremap(&dev->dev, res);