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: <Yxip0d2bBOi/CB4P@kroah.com>
Date:   Wed, 7 Sep 2022 16:25:21 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Dongliang Mu <dzm91@...t.edu.cn>
Cc:     Dongliang Mu <mudongliangabcd@...il.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: misc: usb3503: call clk_disable_unprepare in the
 error handling

On Sat, Sep 03, 2022 at 03:15:40PM +0800, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@...il.com>
> 
> Smatch reports the following warning:
> 
> vers/usb/misc/usb3503.c:267 usb3503_probe() warn: 'hub->clk'
> from clk_prepare_enable() not released on lines: 240,246,252
> 
> Fix this by adding a flag to indicate if hub->clk is prepared or not and
> invoke clk_disable_unprepare in the error handling.
> 
> Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
> ---
>  drivers/usb/misc/usb3503.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
> index 330f494cd158..add47dd964b2 100644
> --- a/drivers/usb/misc/usb3503.c
> +++ b/drivers/usb/misc/usb3503.c
> @@ -160,6 +160,7 @@ static int usb3503_probe(struct usb3503 *hub)
>  	struct usb3503_platform_data *pdata = dev_get_platdata(dev);
>  	struct device_node *np = dev->of_node;
>  	int err;
> +	int is_clk_enable = 0;

bool?

>  	u32 mode = USB3503_MODE_HUB;
>  	const u32 *property;
>  	enum gpiod_flags flags;
> @@ -217,6 +218,8 @@ static int usb3503_probe(struct usb3503 *hub)
>  			return err;
>  		}
>  
> +		// set a flag for successful clk_prepare_enable

Comment isn't needed.

> +		is_clk_enable = 1;
>  		property = of_get_property(np, "disabled-ports", &len);
>  		if (property && (len / sizeof(u32)) > 0) {
>  			int i;
> @@ -236,20 +239,29 @@ static int usb3503_probe(struct usb3503 *hub)
>  	else
>  		flags = GPIOD_OUT_HIGH;
>  	hub->intn = devm_gpiod_get_optional(dev, "intn", flags);
> -	if (IS_ERR(hub->intn))
> +	if (IS_ERR(hub->intn)) {
> +		if (is_clk_enable)
> +			clk_disable_unprepare(hub->clk);
>  		return PTR_ERR(hub->intn);

This is getting messy, any way to make a common error handler at the
bottom of the function instead?  That's the common kernel coding style
for this type of thing.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ