Skip to contentSkip to conversation

pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()

PATCH New Vladimir Zapolskiy 3 participants 3 messages Mar 6, 2016 – Mar 7, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()

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.

Fixes 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")
---
 drivers/pwm/pwm-brcmstb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-brcmstb.c +2 -2
index 423ce08..5d5adee 100644
@@ -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;
 	}
 
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()

Le 05/03/2016 17:21, Vladimir Zapolskiy a ?crit :

Quoted 8 lines

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.

Fixes 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")

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

Signature · 1 line
Florian
#2 lore raw

PATCH 1/1 pwm: bcm7038: fix check of error code returned by devm_ioremap_resource()

In reply to Vladimir Zapolskiy
Quoted 11 lines · Vladimir Zapolskiy

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.

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160307/c15a84f9/attachment.sig>