Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1334948 > unrolled thread

[PATCH] gpio-mcp23s08: correctly handling failed allocation

Started byInsu Yun <wuninsu@gmail.com>
First post2016-02-16 03:30 +0100
Last post2016-02-16 16:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] gpio-mcp23s08: correctly handling failed allocation Insu Yun <wuninsu@gmail.com> - 2016-02-16 03:30 +0100
    Re: [PATCH] gpio-mcp23s08: correctly handling failed allocation Linus Walleij <linus.walleij@linaro.org> - 2016-02-16 16:40 +0100

#1334948 — [PATCH] gpio-mcp23s08: correctly handling failed allocation

FromInsu Yun <wuninsu@gmail.com>
Date2016-02-16 03:30 +0100
Subject[PATCH] gpio-mcp23s08: correctly handling failed allocation
Message-ID<r2DyO-1ku-17@gated-at.bofh.it>
Since devm_kzalloc can be failed in memory pressure,
it needs to check and return -ENOMEM

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/gpio/gpio-mcp23s08.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index c767879..ed51dcf 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -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;
 		}
 	}
-- 
1.9.1

[toc] | [next] | [standalone]


#1335535

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-02-16 16:40 +0100
Message-ID<r2PTk-1fi-19@gated-at.bofh.it>
In reply to#1334948
On Tue, Feb 16, 2016 at 3:19 AM, Insu Yun <wuninsu@gmail.com> wrote:

> Since devm_kzalloc can be failed in memory pressure,
> it needs to check and return -ENOMEM
>
> Signed-off-by: Insu Yun <wuninsu@gmail.com>

Patch applied.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web