linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe
@ 2023-11-29 13:29 Haoran Liu
  2023-11-29 13:43 ` Nicolas Ferre
  2023-11-29 17:15 ` Alexandre Belloni
  0 siblings, 2 replies; 3+ messages in thread
From: Haoran Liu @ 2023-11-29 13:29 UTC (permalink / raw)
  To: claudiu.beznea
  Cc: alexandre.belloni, Haoran Liu, linux-pm, linux-kernel, sre,
	linux-arm-kernel

This patch adds error handling to the at91_shdwc_probe function
in drivers/power/reset/at91-sama5d2_shdwc.c. The function
previously did not handle the case where of_match_node could fail,
potentially leading to unexpected behavior if the device tree match
was unsuccessful.

Signed-off-by: Haoran Liu <liuhaoran14@163.com>
---
 drivers/power/reset/at91-sama5d2_shdwc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
index e76b102b57b1..2ac566c83aec 100644
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -353,6 +353,11 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
 		return PTR_ERR(at91_shdwc->shdwc_base);
 
 	match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
+	if (!match) {
+		dev_err(&pdev->dev, "No matching device found\n");
+		return -ENODEV;
+	}
+
 	at91_shdwc->rcfg = match->data;
 
 	at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe
  2023-11-29 13:29 [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe Haoran Liu
@ 2023-11-29 13:43 ` Nicolas Ferre
  2023-11-29 17:15 ` Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2023-11-29 13:43 UTC (permalink / raw)
  To: Haoran Liu, claudiu.beznea
  Cc: sre, alexandre.belloni, linux-pm, linux-arm-kernel, linux-kernel

On 29/11/2023 at 14:29, Haoran Liu wrote:
> This patch adds error handling to the at91_shdwc_probe function
> in drivers/power/reset/at91-sama5d2_shdwc.c. The function

As the platforms are DT only and that this driver was instantiated 
precisely because a "match" existed, I don't think this error handling 
is needed because it cannot happen.

> previously did not handle the case where of_match_node could fail,
> potentially leading to unexpected behavior if the device tree match
> was unsuccessful.

You didn't say how you reached this "unexpected behavior": is it a real 
case (I'm interested in the boot log then) or found running a static 
analysis tool?

For now, it's a NACK, sorry. Best regards,
   Nicolas

> Signed-off-by: Haoran Liu <liuhaoran14@163.com>
> ---
>   drivers/power/reset/at91-sama5d2_shdwc.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
> index e76b102b57b1..2ac566c83aec 100644
> --- a/drivers/power/reset/at91-sama5d2_shdwc.c
> +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
> @@ -353,6 +353,11 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
>                  return PTR_ERR(at91_shdwc->shdwc_base);
> 
>          match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
> +       if (!match) {
> +               dev_err(&pdev->dev, "No matching device found\n");
> +               return -ENODEV;
> +       }
> +
>          at91_shdwc->rcfg = match->data;
> 
>          at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
> --
> 2.17.1
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe
  2023-11-29 13:29 [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe Haoran Liu
  2023-11-29 13:43 ` Nicolas Ferre
@ 2023-11-29 17:15 ` Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2023-11-29 17:15 UTC (permalink / raw)
  To: Haoran Liu; +Cc: linux-pm, linux-kernel, sre, claudiu.beznea, linux-arm-kernel

On 29/11/2023 05:29:39-0800, Haoran Liu wrote:
> This patch adds error handling to the at91_shdwc_probe function
> in drivers/power/reset/at91-sama5d2_shdwc.c. The function
> previously did not handle the case where of_match_node could fail,
> potentially leading to unexpected behavior if the device tree match
> was unsuccessful.
> 
> Signed-off-by: Haoran Liu <liuhaoran14@163.com>
> ---
>  drivers/power/reset/at91-sama5d2_shdwc.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
> index e76b102b57b1..2ac566c83aec 100644
> --- a/drivers/power/reset/at91-sama5d2_shdwc.c
> +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
> @@ -353,6 +353,11 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
>  		return PTR_ERR(at91_shdwc->shdwc_base);
>  
>  	match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
> +	if (!match) {

Can you elaborate how this will ever happen?

> +		dev_err(&pdev->dev, "No matching device found\n");
> +		return -ENODEV;
> +	}
> +
>  	at91_shdwc->rcfg = match->data;
>  
>  	at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
> -- 
> 2.17.1
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2023-11-29 17:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 13:29 [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe Haoran Liu
2023-11-29 13:43 ` Nicolas Ferre
2023-11-29 17:15 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).