mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node
@ 2024-02-16 22:03 Ahmad Fatoum
  2024-02-16 23:05 ` Marco Felsch
  2024-02-19  8:01 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-02-16 22:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

All callers of of_find_i2c_adapter_by_node expect errors to be indicated
by NULL and don't check non-NULL pointers with IS_ERR().

Therefore map of_device_ensure_probed() errors to NULL as well to avoid
dereferencing error pointers.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/i2c/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
index 70d1b810c1c3..1985ddfdc776 100644
--- a/drivers/i2c/i2c.c
+++ b/drivers/i2c/i2c.c
@@ -593,7 +593,7 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
 
 	ret = of_device_ensure_probed(node);
 	if (ret)
-		return ERR_PTR(ret);
+		return NULL;
 
 	for_each_i2c_adapter(adap)
 		if (adap->dev.of_node == node)
-- 
2.39.2




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

* Re: [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node
  2024-02-16 22:03 [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node Ahmad Fatoum
@ 2024-02-16 23:05 ` Marco Felsch
  2024-02-19  8:01 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Felsch @ 2024-02-16 23:05 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On 24-02-16, Ahmad Fatoum wrote:
> All callers of of_find_i2c_adapter_by_node expect errors to be indicated
> by NULL and don't check non-NULL pointers with IS_ERR().

Good catch.

> Therefore map of_device_ensure_probed() errors to NULL as well to avoid
> dereferencing error pointers.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

> ---
>  drivers/i2c/i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c
> index 70d1b810c1c3..1985ddfdc776 100644
> --- a/drivers/i2c/i2c.c
> +++ b/drivers/i2c/i2c.c
> @@ -593,7 +593,7 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
>  
>  	ret = of_device_ensure_probed(node);
>  	if (ret)
> -		return ERR_PTR(ret);
> +		return NULL;
>  
>  	for_each_i2c_adapter(adap)
>  		if (adap->dev.of_node == node)
> -- 
> 2.39.2
> 
> 
> 



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

* Re: [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node
  2024-02-16 22:03 [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node Ahmad Fatoum
  2024-02-16 23:05 ` Marco Felsch
@ 2024-02-19  8:01 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-02-19  8:01 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Fri, 16 Feb 2024 23:03:37 +0100, Ahmad Fatoum wrote:
> All callers of of_find_i2c_adapter_by_node expect errors to be indicated
> by NULL and don't check non-NULL pointers with IS_ERR().
> 
> Therefore map of_device_ensure_probed() errors to NULL as well to avoid
> dereferencing error pointers.
> 
> 
> [...]

Applied, thanks!

[1/1] i2c: don't return error pointers from of_find_i2c_adapter_by_node
      https://git.pengutronix.de/cgit/barebox/commit/?id=70b782b6b222 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-02-19  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 22:03 [PATCH master] i2c: don't return error pointers from of_find_i2c_adapter_by_node Ahmad Fatoum
2024-02-16 23:05 ` Marco Felsch
2024-02-19  8:01 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox