diff mbox

[RFT] gpio: etraxfs: Fix devm_ioremap_resource return value check

Message ID 1436447993-24630-1-git-send-email-k.kozlowski.k@gmail.com
State New
Headers show

Commit Message

Krzysztof Kozlowski July 9, 2015, 1:19 p.m. UTC
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 <k.kozlowski.k@gmail.com>
Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
Cc: <stable@vger.kernel.org>

---

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

Comments

Alexandre Courbot July 13, 2015, 2:36 p.m. UTC | #1
On Thu, Jul 9, 2015 at 10:19 PM, Krzysztof Kozlowski
<k.kozlowski.k@gmail.com> 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 <acourbot@nvidia.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij July 16, 2015, 1:52 p.m. UTC | #2
On Thu, Jul 9, 2015 at 3:19 PM, Krzysztof Kozlowski
<k.kozlowski.k@gmail.com> 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 <k.kozlowski.k@gmail.com>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
> Cc: <stable@vger.kernel.org>
>
> ---
>
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rabin Vincent July 16, 2015, 5:36 p.m. UTC | #3
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 <k.kozlowski.k@gmail.com>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")

Acked-by: Rabin Vincent <rabin@rab.in>

> Cc: <stable@vger.kernel.org>

I don't think this demands a stable backport though.
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij July 17, 2015, 7:49 a.m. UTC | #4
On Thu, Jul 9, 2015 at 3:19 PM, Krzysztof Kozlowski
<k.kozlowski.k@gmail.com> 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 <k.kozlowski.k@gmail.com>
> Fixes: d342571efea8 ("gpio: add ETRAXFS GPIO driver")
> Cc: <stable@vger.kernel.org>

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

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)