pwm: brcmstb: Fix check of devm_ioremap_resource() return code
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 6 Mar 2016 01:21:46 +0000 (03:21 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 23 Mar 2016 16:11:45 +0000 (17:11 +0100)
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>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-brcmstb.c

index 423ce087cd9c881168bb6894c89041fc0cf522cc..5d5adee1688624ed4123ae9f6fbb821e6e337364 100644 (file)
@@ -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;
        }