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


Groups > linux.kernel > #1351020 > unrolled thread

[PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()

Started byVladimir Zapolskiy <vz@mleia.com>
First post2016-03-06 02:30 +0100
Last post2016-03-06 04:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource() Vladimir Zapolskiy <vz@mleia.com> - 2016-03-06 02:30 +0100
    Re: [PATCH] mailbox: sti: fix check of error code returned by  devm_ioremap_resource() Lee Jones <lee.jones@linaro.org> - 2016-03-06 04:10 +0100

#1351020 — [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()

FromVladimir Zapolskiy <vz@mleia.com>
Date2016-03-06 02:30 +0100
Subject[PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()
Message-ID<r9vGa-6nu-7@gated-at.bofh.it>
The change fixes potential oops while accessing iomem on invalid
address, if devm_ioremap_resource() fails due to some reason.

The devm_ioremap_resource() function returns ERR_PTR() and never
returns NULL, which makes useless a following check for NULL.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Fixes: 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP")
---
 drivers/mailbox/mailbox-sti.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c
index 2394cfe..a334db5 100644
--- a/drivers/mailbox/mailbox-sti.c
+++ b/drivers/mailbox/mailbox-sti.c
@@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mdev->base = devm_ioremap_resource(&pdev->dev, res);
-	if (!mdev->base)
-		return -ENOMEM;
+	if (IS_ERR(mdev->base))
+		return PTR_ERR(mdev->base);
 
 	ret = of_property_read_string(np, "mbox-name", &mdev->name);
 	if (ret)
-- 
2.1.4

[toc] | [next] | [standalone]


#1351034 — Re: [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()

FromLee Jones <lee.jones@linaro.org>
Date2016-03-06 04:10 +0100
SubjectRe: [PATCH] mailbox: sti: fix check of error code returned by devm_ioremap_resource()
Message-ID<r9xeV-7sG-7@gated-at.bofh.it>
In reply to#1351020
On Sun, 06 Mar 2016, Vladimir Zapolskiy wrote:

> The change fixes potential oops while accessing iomem on invalid
> address, if devm_ioremap_resource() fails due to some reason.
> 
> The devm_ioremap_resource() function returns ERR_PTR() and never
> returns NULL, which makes useless a following check for NULL.
> 
> Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
> Fixes: 9ef4546cbd7e ("mailbox: Add support for ST's Mailbox IP")
> ---
>  drivers/mailbox/mailbox-sti.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c
> index 2394cfe..a334db5 100644
> --- a/drivers/mailbox/mailbox-sti.c
> +++ b/drivers/mailbox/mailbox-sti.c
> @@ -430,8 +430,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	mdev->base = devm_ioremap_resource(&pdev->dev, res);
> -	if (!mdev->base)
> -		return -ENOMEM;
> +	if (IS_ERR(mdev->base))
> +		return PTR_ERR(mdev->base);
>  
>  	ret = of_property_read_string(np, "mbox-name", &mdev->name);
>  	if (ret)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web