2017-09-21 05:15:14

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH v2 1/2] gpio: brcmstb: Handle return value of devm_kasprintf

devm_kasprintf() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <[email protected]>
---
changes in v2 :
Set return 'err' to -ENOMEM.

drivers/gpio/gpio-brcmstb.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index dd0308c..27e92e5 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -485,6 +485,10 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
gc->of_node = np;
gc->owner = THIS_MODULE;
gc->label = devm_kasprintf(dev, GFP_KERNEL, "%pOF", dev->of_node);
+ if (!gc->label) {
+ err = -ENOMEM;
+ goto fail;
+ }
gc->base = gpio_base;
gc->of_gpio_n_cells = 2;
gc->of_xlate = brcmstb_gpio_of_xlate;
--
1.9.1


2017-09-21 12:13:44

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] gpio: brcmstb: Handle return value of devm_kasprintf

On Thu, Sep 21, 2017 at 7:14 AM, Arvind Yadav <[email protected]> wrote:

> devm_kasprintf() can fail here and we must check its return value.
>
> Signed-off-by: Arvind Yadav <[email protected]>
> ---
> changes in v2 :
> Set return 'err' to -ENOMEM.

Patch applied.

Yours,
Linus Walleij