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: <d1955b9e-c719-9c7c-b1fd-f11fa97e44af@collabora.com>
Date:   Wed, 17 May 2023 12:40:37 +0200
From:   AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
To:     Shreeya Patel <shreeya.patel@...labora.com>, jic23@...nel.org,
        lars@...afoo.de, heiko@...ech.de, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, sebastian.reichel@...labora.com
Cc:     linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org,
        kernel@...labora.com, gustavo.padovan@...labora.com,
        serge.broslavsky@...labora.com
Subject: Re: [PATCH 5/7] iio: adc: rockchip_saradc: Use dev_err_probe

Il 17/05/23 01:00, Shreeya Patel ha scritto:
> Use dev_err_probe instead of dev_err in probe function,
> which simplifies code a little bit and prints the error
> code.
> 
> Signed-off-by: Shreeya Patel <shreeya.patel@...labora.com>
> ---
>   drivers/iio/adc/rockchip_saradc.c | 45 ++++++++++++++-----------------
>   1 file changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> index 5e1e8575bc76..a52021fd477d 100644
> --- a/drivers/iio/adc/rockchip_saradc.c
> +++ b/drivers/iio/adc/rockchip_saradc.c

..snip..

> @@ -494,23 +492,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
>   	 * This may become user-configurable in the future.
>   	 */
>   	ret = clk_set_rate(info->clk, info->data->clk_rate);
> -	if (ret < 0) {
> -		dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		return dev_err_probe(&pdev->dev, ret,
> +				     "failed to set adc clk rate\n");
>   
>   	ret = regulator_enable(info->vref);
> -	if (ret < 0) {
> -		dev_err(&pdev->dev, "failed to enable vref regulator\n");
> -		return ret;
> -	}
> +	if (ret < 0)
> +		return dev_err_probe(&pdev->dev, ret,
> +				     "failed to enable vref regulator\n");
> +
>   	ret = devm_add_action_or_reset(&pdev->dev,
>   				       rockchip_saradc_regulator_disable, info);
> -	if (ret) {
> -		dev_err(&pdev->dev, "failed to register devm action, %d\n",
> -			ret);
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(&pdev->dev, ret,
> +				     "failed to register devm action\n");

It's not your fault - and it's about a pre-existing issue, but there's that:
you're returning an error if devm_add_action_or_reset() fails (which is highly
unlikely), but you're leaving the regulator enabled!

As for how to proceed here, I would suggest to fix this issue in a separated
commit (before the dev_err_probe() conversion); it'd look like...

	if (ret) {
		regulator_disable(info->vref);
		dev_err( .... blurb );
		return ret;
	}

and after the conversion it'd look like...

	if (ret) {
		regulator_disable(info->vref);
		return dev_err_probe( ... blurb );
	}

Cheers,
Angelo

>   
>   	ret = regulator_get_voltage(info->vref);
>   	if (ret < 0)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ