[PATCH] Signed-off-by: Wenyuan Li <2063309626@qq.com> spi: hi311x: Add check for hi3110_power_enable() return value In hi3110_open(), the return value of hi3110_power_enable() is not checked. If power enable fails, the device may not function correctly, while the driver still returns success.

Wenyuan Li posted 1 patch 1 month ago
There is a newer version of this series
drivers/net/can/spi/hi311x.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] Signed-off-by: Wenyuan Li <2063309626@qq.com> spi: hi311x: Add check for hi3110_power_enable() return value In hi3110_open(), the return value of hi3110_power_enable() is not checked. If power enable fails, the device may not function correctly, while the driver still returns success.
Posted by Wenyuan Li 1 month ago
Add a check for the return value and propagate the error accordingly.

Signed-off-by: Wenyuan Li <2063309626@qq.com>
---
 drivers/net/can/spi/hi311x.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
index e00d3dbc4cf4..f0444b4c5b6e 100644
--- a/drivers/net/can/spi/hi311x.c
+++ b/drivers/net/can/spi/hi311x.c
@@ -755,8 +755,9 @@ static int hi3110_open(struct net_device *net)
 		return ret;
 
 	mutex_lock(&priv->hi3110_lock);
-	hi3110_power_enable(priv->transceiver, 1);
-
+	ret = hi3110_power_enable(priv->transceiver, 1);
+	if (ret)
+		goto out_disable;
 	priv->force_quit = 0;
 	priv->tx_skb = NULL;
 	priv->tx_busy = false;
@@ -790,6 +791,7 @@ static int hi3110_open(struct net_device *net)
 	hi3110_hw_sleep(spi);
  out_close:
 	hi3110_power_enable(priv->transceiver, 0);
+ out_disable:
 	close_candev(net);
 	mutex_unlock(&priv->hi3110_lock);
 	return ret;
-- 
2.43.0
Re: [PATCH] spi: hi311x: Add check for hi3110_power_enable() return value
Posted by Marc Kleine-Budde 4 weeks, 1 day ago
On 10.03.2026 13:08:44, Wenyuan Li wrote:
> Add a check for the return value and propagate the error accordingly.
>
> Signed-off-by: Wenyuan Li <2063309626@qq.com>

Applied with fixed subject/patch description...

> ---
>  drivers/net/can/spi/hi311x.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
> index e00d3dbc4cf4..f0444b4c5b6e 100644
> --- a/drivers/net/can/spi/hi311x.c
> +++ b/drivers/net/can/spi/hi311x.c
> @@ -755,8 +755,9 @@ static int hi3110_open(struct net_device *net)
>  		return ret;
>
>  	mutex_lock(&priv->hi3110_lock);
> -	hi3110_power_enable(priv->transceiver, 1);
> -
> +	ret = hi3110_power_enable(priv->transceiver, 1);
> +	if (ret)
> +		goto out_disable;

...and renamed jump label to out_close_candev

>  	priv->force_quit = 0;
>  	priv->tx_skb = NULL;
>  	priv->tx_busy = false;
> @@ -790,6 +791,7 @@ static int hi3110_open(struct net_device *net)
>  	hi3110_hw_sleep(spi);
>   out_close:
>  	hi3110_power_enable(priv->transceiver, 0);
> + out_disable:
>  	close_candev(net);
>  	mutex_unlock(&priv->hi3110_lock);
>  	return ret;

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |