2015-07-09 13:20:33

by Krzysztof Kozłowski

[permalink] [raw]
Subject: [RFT PATCH] gpio: etraxfs: Fix devm_ioremap_resource return value check

Value returned by devm_ioremap_resource() was checked for non-NULL but
devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
error this could lead to dereference of ERR_PTR.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
Cc: <[email protected]>

---

Patch only compile tested.
---
drivers/gpio/gpio-etraxfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c
index 28071f4a5672..0e643140efde 100644
--- a/drivers/gpio/gpio-etraxfs.c
+++ b/drivers/gpio/gpio-etraxfs.c
@@ -117,8 +117,8 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(dev, res);
- if (!regs)
- return -ENOMEM;
+ if (IS_ERR(regs))
+ return PTR_ERR(regs);

match = of_match_node(etraxfs_gpio_of_table, dev->of_node);
if (!match)
--
2.1.4


2015-07-13 14:37:10

by Alexandre Courbot

[permalink] [raw]
Subject: Re: [RFT PATCH] gpio: etraxfs: Fix devm_ioremap_resource return value check

On Thu, Jul 9, 2015 at 10:19 PM, Krzysztof Kozlowski
<[email protected]> wrote:
> Value returned by devm_ioremap_resource() was checked for non-NULL but
> devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
> error this could lead to dereference of ERR_PTR.

Look obvious enough to be merged without testing.

Acked-by: Alexandre Courbot <[email protected]>

2015-07-16 13:52:22

by Linus Walleij

[permalink] [raw]
Subject: Re: [RFT PATCH] gpio: etraxfs: Fix devm_ioremap_resource return value check

On Thu, Jul 9, 2015 at 3:19 PM, Krzysztof Kozlowski
<[email protected]> wrote:

> Value returned by devm_ioremap_resource() was checked for non-NULL but
> devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
> error this could lead to dereference of ERR_PTR.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
> Cc: <[email protected]>
>
> ---
>
> Patch only compile tested.
> ---
> drivers/gpio/gpio-etraxfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c
> index 28071f4a5672..0e643140efde 100644
> --- a/drivers/gpio/gpio-etraxfs.c
> +++ b/drivers/gpio/gpio-etraxfs.c
> @@ -117,8 +117,8 @@ static int etraxfs_gpio_probe(struct platform_device *pdev)
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> regs = devm_ioremap_resource(dev, res);
> - if (!regs)
> - return -ENOMEM;
> + if (IS_ERR(regs))
> + return PTR_ERR(regs);
>
> match = of_match_node(etraxfs_gpio_of_table, dev->of_node);
> if (!match)

Rabin, can you ACK this?

Yours,
Linus Walleij

2015-07-16 17:37:09

by Rabin Vincent

[permalink] [raw]
Subject: Re: [RFT PATCH] gpio: etraxfs: Fix devm_ioremap_resource return value check

On Thu, Jul 09, 2015 at 10:19:53PM +0900, Krzysztof Kozlowski wrote:
> Value returned by devm_ioremap_resource() was checked for non-NULL but
> devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
> error this could lead to dereference of ERR_PTR.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")

Acked-by: Rabin Vincent <[email protected]>

> Cc: <[email protected]>

I don't think this demands a stable backport though.

2015-07-17 07:49:27

by Linus Walleij

[permalink] [raw]
Subject: Re: [RFT PATCH] gpio: etraxfs: Fix devm_ioremap_resource return value check

On Thu, Jul 9, 2015 at 3:19 PM, Krzysztof Kozlowski
<[email protected]> wrote:

> Value returned by devm_ioremap_resource() was checked for non-NULL but
> devm_ioremap_resource() returns IOMEM_ERR_PTR, not NULL. In case of
> error this could lead to dereference of ERR_PTR.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
> Cc: <[email protected]>

Patch applied for next cycle, stripped the Fixes: and stable tags.

Yours,
Linus Walleij