diff mbox series

media: tw9910: add missed clk_disable_unprepare() on failure path

Message ID 1546119320-11841-1-git-send-email-khoroshilov@ispras.ru (mailing list archive)
State New, archived
Headers show
Series media: tw9910: add missed clk_disable_unprepare() on failure path | expand

Commit Message

Alexey Khoroshilov Dec. 29, 2018, 9:35 p.m. UTC
If gpiod_get_optional() fails in tw9910_power_on(), clk is left undisabled.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/media/i2c/tw9910.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jacopo Mondi Dec. 30, 2018, 9:49 a.m. UTC | #1
Hi Alexey,
   thanks for the patch

On Sun, Dec 30, 2018 at 12:35:20AM +0300, Alexey Khoroshilov wrote:
> If gpiod_get_optional() fails in tw9910_power_on(), clk is left undisabled.
>

Correct, thanks for spotting this.

I think pdn_gpio should also be handled if rstb_gpio fails.
What's your opinion?

Thanks
  j

> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/media/i2c/tw9910.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c
> index a54548cc4285..109770d678d2 100644
> --- a/drivers/media/i2c/tw9910.c
> +++ b/drivers/media/i2c/tw9910.c
> @@ -610,6 +610,7 @@ static int tw9910_power_on(struct tw9910_priv *priv)
>  					     GPIOD_OUT_LOW);
>  	if (IS_ERR(priv->rstb_gpio)) {
>  		dev_info(&client->dev, "Unable to get GPIO \"rstb\"");
> +		clk_disable_unprepare(priv->clk);
>  		return PTR_ERR(priv->rstb_gpio);
>  	}
>
> --
> 2.7.4
>
Alexey Khoroshilov Dec. 30, 2018, 11:17 a.m. UTC | #2
Hi Jacopo,

On 30.12.2018 12:49, Jacopo Mondi wrote:
> On Sun, Dec 30, 2018 at 12:35:20AM +0300, Alexey Khoroshilov wrote:
>> If gpiod_get_optional() fails in tw9910_power_on(), clk is left undisabled.
> 
> Correct, thanks for spotting this.
> 
> I think pdn_gpio should also be handled if rstb_gpio fails.
> What's your opinion?

I would agree. I'll send v2.

Thank you,
Alexey

> 
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> ---
>>  drivers/media/i2c/tw9910.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c
>> index a54548cc4285..109770d678d2 100644
>> --- a/drivers/media/i2c/tw9910.c
>> +++ b/drivers/media/i2c/tw9910.c
>> @@ -610,6 +610,7 @@ static int tw9910_power_on(struct tw9910_priv *priv)
>>  					     GPIOD_OUT_LOW);
>>  	if (IS_ERR(priv->rstb_gpio)) {
>>  		dev_info(&client->dev, "Unable to get GPIO \"rstb\"");
>> +		clk_disable_unprepare(priv->clk);
>>  		return PTR_ERR(priv->rstb_gpio);
>>  	}
>>
>> --
>> 2.7.4
>>
diff mbox series

Patch

diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c
index a54548cc4285..109770d678d2 100644
--- a/drivers/media/i2c/tw9910.c
+++ b/drivers/media/i2c/tw9910.c
@@ -610,6 +610,7 @@  static int tw9910_power_on(struct tw9910_priv *priv)
 					     GPIOD_OUT_LOW);
 	if (IS_ERR(priv->rstb_gpio)) {
 		dev_info(&client->dev, "Unable to get GPIO \"rstb\"");
+		clk_disable_unprepare(priv->clk);
 		return PTR_ERR(priv->rstb_gpio);
 	}