linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()
@ 2016-03-06  1:21 Vladimir Zapolskiy
  2016-03-07  1:15 ` Florian Fainelli
  2016-03-07  9:19 ` Thierry Reding
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Zapolskiy @ 2016-03-06  1:21 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Brian Norris, Gregory Fong, Florian Fainelli, linux-pwm,
	linux-arm-kernel, bcm-kernel-feedback-list

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: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")
---
 drivers/pwm/pwm-brcmstb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
index 423ce08..5d5adee 100644
--- a/drivers/pwm/pwm-brcmstb.c
+++ b/drivers/pwm/pwm-brcmstb.c
@@ -274,8 +274,8 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	p->base = devm_ioremap_resource(&pdev->dev, res);
-	if (!p->base) {
-		ret = -ENOMEM;
+	if (IS_ERR(p->base)) {
+		ret = PTR_ERR(p->base);
 		goto out_clk;
 	}
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()
  2016-03-06  1:21 [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource() Vladimir Zapolskiy
@ 2016-03-07  1:15 ` Florian Fainelli
  2016-03-07  9:19 ` Thierry Reding
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2016-03-07  1:15 UTC (permalink / raw)
  To: Vladimir Zapolskiy, Thierry Reding
  Cc: Brian Norris, Gregory Fong, linux-pwm, linux-arm-kernel,
	bcm-kernel-feedback-list

Le 05/03/2016 17:21, Vladimir Zapolskiy a écrit :
> 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: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

Using pwm: brcmstb for the subject might be a better fit to match the
filename, but this is bike shedding.
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()
  2016-03-06  1:21 [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource() Vladimir Zapolskiy
  2016-03-07  1:15 ` Florian Fainelli
@ 2016-03-07  9:19 ` Thierry Reding
  1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2016-03-07  9:19 UTC (permalink / raw)
  To: Vladimir Zapolskiy
  Cc: Brian Norris, Gregory Fong, Florian Fainelli, linux-pwm,
	linux-arm-kernel, bcm-kernel-feedback-list

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

On Sun, Mar 06, 2016 at 03:21:46AM +0200, 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: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")
> ---
>  drivers/pwm/pwm-brcmstb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-07  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-06  1:21 [PATCH] pwm: bcm7038: fix check of error code returned by devm_ioremap_resource() Vladimir Zapolskiy
2016-03-07  1:15 ` Florian Fainelli
2016-03-07  9:19 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).