lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1d3f57c-774a-840d-f811-1b91cc40079a@linux.alibaba.com>
Date:   Fri, 13 Oct 2023 11:35:52 +0800
From:   Baolin Wang <baolin.wang@...ux.alibaba.com>
To:     Chunyan Zhang <chunyan.zhang@...soc.com>,
        Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>
Cc:     linux-leds@...r.kernel.org, Orson Zhai <orsonzhai@...il.com>,
        Chunyan Zhang <zhang.lyra@...il.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V3] leds: sc27xx: Move mutex_init() down



On 10/13/2023 10:20 AM, Chunyan Zhang wrote:
> Move the mutex_init() to avoid redundant mutex_destroy() calls after
> that for each time the probe fails.
> 
> Signed-off-by: Chunyan Zhang <chunyan.zhang@...soc.com>

LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@...ux.alibaba.com>

> ---
> Rebased onto linux-next.
> 
> V3: Move the mutex_init() before sc27xx_led_register(), in case it maybe
> used right after led registerd.
> 
> V2: Move the mutex_init() to the end of .probe() instead of adding mutex_destroy().
> ---
>   drivers/leds/leds-sc27xx-bltc.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c
> index af1f00a2f328..f04db793e8d6 100644
> --- a/drivers/leds/leds-sc27xx-bltc.c
> +++ b/drivers/leds/leds-sc27xx-bltc.c
> @@ -296,7 +296,6 @@ static int sc27xx_led_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   
>   	platform_set_drvdata(pdev, priv);
> -	mutex_init(&priv->lock);
>   	priv->base = base;
>   	priv->regmap = dev_get_regmap(dev->parent, NULL);
>   	if (!priv->regmap) {
> @@ -309,13 +308,11 @@ static int sc27xx_led_probe(struct platform_device *pdev)
>   		err = of_property_read_u32(child, "reg", &reg);
>   		if (err) {
>   			of_node_put(child);
> -			mutex_destroy(&priv->lock);
>   			return err;
>   		}
>   
>   		if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) {
>   			of_node_put(child);
> -			mutex_destroy(&priv->lock);
>   			return -EINVAL;
>   		}
>   
> @@ -323,6 +320,8 @@ static int sc27xx_led_probe(struct platform_device *pdev)
>   		priv->leds[reg].active = true;
>   	}
>   
> +	mutex_init(&priv->lock);
> +
>   	err = sc27xx_led_register(dev, priv);
>   	if (err)
>   		mutex_destroy(&priv->lock);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ