Hi Wei

Thank you for your patch

> From: Wei Yongjun <[email protected]>
> 
> Add the missing unlock before return from function rcar_thermal_update_temp()
> in the error handling case.
> 
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
>  drivers/thermal/rcar_thermal.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 909bb4b..fe694be 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -174,6 +174,7 @@ static int rcar_thermal_update_temp(struct 
> rcar_thermal_priv *priv)
>  
>       if (!ctemp) {
>               dev_err(dev, "thermal sensor was broken\n");
> +             mutex_unlock(&priv->lock);
>               return -EINVAL;
>       }

Nice catch !

But, can you use goto for readable code ?
like this

   int ret = -EINVAL;

   mutex_lock(&priv->lock);
   ...
   if (!ctemp) {
       dev_err(dev, "thermal sensor was broken\n");
       goto rcar_thermal_update_temp_error:
    }
    ...

    ret = 0;
rcar_thermal_update_temp_error:
    mutex_unlock(&priv->lock);
    return ret;        


Best regards
---
Kuninori Morimoto
_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

Reply via email to