linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: sc27xx: Add a missing mutex_destory()
@ 2023-09-21  2:43 Chunyan Zhang
  2023-09-21 12:05 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyan Zhang @ 2023-09-21  2:43 UTC (permalink / raw)
  To: Pavel Machek, Lee Jones
  Cc: linux-leds, Baolin Wang, Orson Zhai, Chunyan Zhang, Chunyan Zhang,
	LKML

In sc27xx_led_probe() there's one error branch missing mutex_destory()
after mutex_init(), it seems that we should add it since other branches
which follow it called mutex_destoy() before return failure.

Fixes: e081c49e30ec ("leds: Add Spreadtrum SC27xx breathing light controller driver")
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
 drivers/leds/leds-sc27xx-bltc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c
index e199ea15e406..122094bbf444 100644
--- a/drivers/leds/leds-sc27xx-bltc.c
+++ b/drivers/leds/leds-sc27xx-bltc.c
@@ -300,6 +300,7 @@ static int sc27xx_led_probe(struct platform_device *pdev)
 	priv->base = base;
 	priv->regmap = dev_get_regmap(dev->parent, NULL);
 	if (!priv->regmap) {
+		mutex_destroy(&priv->lock);
 		err = -ENODEV;
 		dev_err(dev, "failed to get regmap: %d\n", err);
 		return err;
-- 
2.41.0


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

* Re: [PATCH] leds: sc27xx: Add a missing mutex_destory()
  2023-09-21  2:43 [PATCH] leds: sc27xx: Add a missing mutex_destory() Chunyan Zhang
@ 2023-09-21 12:05 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2023-09-21 12:05 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Pavel Machek, linux-leds, Baolin Wang, Orson Zhai, Chunyan Zhang,
	LKML

On Thu, 21 Sep 2023, Chunyan Zhang wrote:

> In sc27xx_led_probe() there's one error branch missing mutex_destory()
> after mutex_init(), it seems that we should add it since other branches
> which follow it called mutex_destoy() before return failure.

Wouldn't it be better to move the mutex_init() to the end of .probe()?

> Fixes: e081c49e30ec ("leds: Add Spreadtrum SC27xx breathing light controller driver")
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> ---
>  drivers/leds/leds-sc27xx-bltc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c
> index e199ea15e406..122094bbf444 100644
> --- a/drivers/leds/leds-sc27xx-bltc.c
> +++ b/drivers/leds/leds-sc27xx-bltc.c
> @@ -300,6 +300,7 @@ static int sc27xx_led_probe(struct platform_device *pdev)
>  	priv->base = base;
>  	priv->regmap = dev_get_regmap(dev->parent, NULL);
>  	if (!priv->regmap) {
> +		mutex_destroy(&priv->lock);
>  		err = -ENODEV;
>  		dev_err(dev, "failed to get regmap: %d\n", err);
>  		return err;
> -- 
> 2.41.0
> 

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2023-09-21 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-21  2:43 [PATCH] leds: sc27xx: Add a missing mutex_destory() Chunyan Zhang
2023-09-21 12:05 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).