Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: qcom: Check for platform_get_resource() failure

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>

authored by

Fabio Estevam and committed by
Wim Van Sebroeck
15210ad1 6f671c6b

+2
+2
drivers/watchdog/qcom-wdt.c
··· 162 162 return -ENOMEM; 163 163 164 164 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 165 + if (!res) 166 + return -ENOMEM; 165 167 166 168 /* We use CPU0's DGT for the watchdog */ 167 169 if (of_property_read_u32(np, "cpu-offset", &percpu_offset))