[PATCH -next] thermal: rcar: fix missing unlock on error in rcar_thermal_update_temp()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Fri Feb 22 17:14:24 EST 2013
Hi Wei
Thank you for your patch
> From: Wei Yongjun <yongjun_wei at trendmicro.com.cn>
>
> Add the missing unlock before return from function rcar_thermal_update_temp()
> in the error handling case.
>
> Signed-off-by: Wei Yongjun <yongjun_wei at trendmicro.com.cn>
> ---
> 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
More information about the devicetree-discuss
mailing list