From: Fabio Estevam Date: Sat, 22 Jul 2017 16:04:33 +0000 (-0300) Subject: watchdog: qcom: Check for platform_get_resource() failure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=15210ad18fcbd7f53f40e26e4391710d271c2daf;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index 4f47b5e90956..780971318810 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -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))