watchdog: qcom: Check for platform_get_resource() failure
authorFabio Estevam <fabio.estevam@nxp.com>
Sat, 22 Jul 2017 16:04:33 +0000 (13:04 -0300)
committerWim Van Sebroeck <wim@iguana.be>
Sat, 9 Sep 2017 18:50:35 +0000 (20:50 +0200)
platform_get_resource() may fail, so we should better check its
return value and propagate an error in case it fails.

This avoids a NULL pointer dereference a bit later in the code.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/qcom-wdt.c

index 4f47b5e..7809713 100644 (file)
@@ -162,6 +162,8 @@ static int qcom_wdt_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENOMEM;
 
        /* We use CPU0's DGT for the watchdog */
        if (of_property_read_u32(np, "cpu-offset", &percpu_offset))