public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: st1202: Fix an error handling path in st1202_probe()
@ 2025-02-19 17:20 Christophe JAILLET
  2025-02-20 15:58 ` Lee Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2025-02-19 17:20 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Vicentiu Galanopulo
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-leds

devm_mutex_init() may return -ENOMEM.
So this error should be handled in st1202_probe().

Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/leds/leds-st1202.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index b691c4886993..4fc17d518292 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -356,7 +356,10 @@ static int st1202_probe(struct i2c_client *client)
 	if (!chip)
 		return -ENOMEM;
 
-	devm_mutex_init(&client->dev, &chip->lock);
+	ret = devm_mutex_init(&client->dev, &chip->lock);
+	if (ret < 0)
+		return ret;
+
 	chip->client = client;
 
 	ret = st1202_dt_init(chip);
-- 
2.48.1


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

* Re: [PATCH] leds: st1202: Fix an error handling path in st1202_probe()
  2025-02-19 17:20 [PATCH] leds: st1202: Fix an error handling path in st1202_probe() Christophe JAILLET
@ 2025-02-20 15:58 ` Lee Jones
  2025-02-23 16:20   ` Christophe JAILLET
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Jones @ 2025-02-20 15:58 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pavel Machek, Vicentiu Galanopulo, linux-kernel, kernel-janitors,
	linux-leds

On Wed, 19 Feb 2025, Christophe JAILLET wrote:

> devm_mutex_init() may return -ENOMEM.
> So this error should be handled in st1202_probe().

The start of a new sentence shouldn't warrant a line break.

> Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/leds/leds-st1202.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
> index b691c4886993..4fc17d518292 100644
> --- a/drivers/leds/leds-st1202.c
> +++ b/drivers/leds/leds-st1202.c
> @@ -356,7 +356,10 @@ static int st1202_probe(struct i2c_client *client)
>  	if (!chip)
>  		return -ENOMEM;
>  
> -	devm_mutex_init(&client->dev, &chip->lock);
> +	ret = devm_mutex_init(&client->dev, &chip->lock);
> +	if (ret < 0)

My assumption is that anything but 0 would be bad, thus:

	if (ret)

> +		return ret;
> +
>  	chip->client = client;
>  
>  	ret = st1202_dt_init(chip);
> -- 
> 2.48.1
> 

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH] leds: st1202: Fix an error handling path in st1202_probe()
  2025-02-20 15:58 ` Lee Jones
@ 2025-02-23 16:20   ` Christophe JAILLET
  2025-02-27 17:50     ` Lee Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2025-02-23 16:20 UTC (permalink / raw)
  To: Lee Jones
  Cc: Pavel Machek, Vicentiu Galanopulo, linux-kernel, kernel-janitors,
	linux-leds

Le 20/02/2025 à 16:58, Lee Jones a écrit :
> On Wed, 19 Feb 2025, Christophe JAILLET wrote:
> 
>> devm_mutex_init() may return -ENOMEM.
>> So this error should be handled in st1202_probe().
> 
> The start of a new sentence shouldn't warrant a line break.
> 
>> Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/leds/leds-st1202.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
>> index b691c4886993..4fc17d518292 100644
>> --- a/drivers/leds/leds-st1202.c
>> +++ b/drivers/leds/leds-st1202.c
>> @@ -356,7 +356,10 @@ static int st1202_probe(struct i2c_client *client)
>>   	if (!chip)
>>   		return -ENOMEM;
>>   
>> -	devm_mutex_init(&client->dev, &chip->lock);
>> +	ret = devm_mutex_init(&client->dev, &chip->lock);
>> +	if (ret < 0)
> 
> My assumption is that anything but 0 would be bad, thus:
> 
> 	if (ret)

Matter of taste. All other tests in this driver are "if (ret < 0)" or 
"if (ret != 0)".

What do you prefer: consistency or concision? (my own choice goes to 
consistency)

If you confirm concision, I'll send a v2 that also fix your other 
comment above.

CJ

> 
>> +		return ret;
>> +
>>   	chip->client = client;
>>   
>>   	ret = st1202_dt_init(chip);
>> -- 
>> 2.48.1
>>
> 


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

* Re: [PATCH] leds: st1202: Fix an error handling path in st1202_probe()
  2025-02-23 16:20   ` Christophe JAILLET
@ 2025-02-27 17:50     ` Lee Jones
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2025-02-27 17:50 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Pavel Machek, Vicentiu Galanopulo, linux-kernel, kernel-janitors,
	linux-leds

On Sun, 23 Feb 2025, Christophe JAILLET wrote:

> Le 20/02/2025 à 16:58, Lee Jones a écrit :
> > On Wed, 19 Feb 2025, Christophe JAILLET wrote:
> > 
> > > devm_mutex_init() may return -ENOMEM.
> > > So this error should be handled in st1202_probe().
> > 
> > The start of a new sentence shouldn't warrant a line break.
> > 
> > > Fixes: 259230378c65 ("leds: Add LED1202 I2C driver")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > ---
> > >   drivers/leds/leds-st1202.c | 5 ++++-
> > >   1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
> > > index b691c4886993..4fc17d518292 100644
> > > --- a/drivers/leds/leds-st1202.c
> > > +++ b/drivers/leds/leds-st1202.c
> > > @@ -356,7 +356,10 @@ static int st1202_probe(struct i2c_client *client)
> > >   	if (!chip)
> > >   		return -ENOMEM;
> > > -	devm_mutex_init(&client->dev, &chip->lock);
> > > +	ret = devm_mutex_init(&client->dev, &chip->lock);
> > > +	if (ret < 0)
> > 
> > My assumption is that anything but 0 would be bad, thus:
> > 
> > 	if (ret)
> 
> Matter of taste. All other tests in this driver are "if (ret < 0)" or "if
> (ret != 0)".
> 
> What do you prefer: consistency or concision? (my own choice goes to
> consistency)
> 
> If you confirm concision, I'll send a v2 that also fix your other comment
> above.

Ah, I just attempted to apply the patch, but it looks like it's already
fixed in ("leds: st1202: Check for error code from devm_mutex_init()
call").

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2025-02-27 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 17:20 [PATCH] leds: st1202: Fix an error handling path in st1202_probe() Christophe JAILLET
2025-02-20 15:58 ` Lee Jones
2025-02-23 16:20   ` Christophe JAILLET
2025-02-27 17:50     ` Lee Jones

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