All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: qcom: Check for platform_get_resource() failure
@ 2017-07-22 16:04 Fabio Estevam
  2017-07-22 21:31 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Fabio Estevam @ 2017-07-22 16:04 UTC (permalink / raw)
  To: wim; +Cc: linux, joshc, linux-watchdog, Fabio Estevam

From: Fabio Estevam <fabio.estevam@nxp.com>

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>
---
 drivers/watchdog/qcom-wdt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index 4f47b5e..7809713 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))
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: qcom: Check for platform_get_resource() failure
  2017-07-22 16:04 [PATCH] watchdog: qcom: Check for platform_get_resource() failure Fabio Estevam
@ 2017-07-22 21:31 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2017-07-22 21:31 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: wim, joshc, linux-watchdog, Fabio Estevam

On Sat, Jul 22, 2017 at 01:04:33PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> 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>

> ---
>  drivers/watchdog/qcom-wdt.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index 4f47b5e..7809713 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))
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-22 21:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-22 16:04 [PATCH] watchdog: qcom: Check for platform_get_resource() failure Fabio Estevam
2017-07-22 21:31 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.