gpio-mcp23s08: correctly handling failed allocation
authorInsu Yun <wuninsu@gmail.com>
Tue, 16 Feb 2016 02:19:57 +0000 (21:19 -0500)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 16 Feb 2016 15:36:22 +0000 (16:36 +0100)
Since devm_kzalloc can be failed in memory pressure,
it needs to check and return -ENOMEM

Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mcp23s08.c

index c767879..f8d4abc 100644 (file)
@@ -803,6 +803,8 @@ static int mcp230xx_probe(struct i2c_client *client,
                        pdata = devm_kzalloc(&client->dev,
                                        sizeof(struct mcp23s08_platform_data),
                                        GFP_KERNEL);
+                       if (!pdata)
+                               return -ENOMEM;
                        pdata->base = -1;
                }
        }