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: <20231115222428.rhykr6e5koyzsyw6@mercury.elektranox.org>
Date:   Wed, 15 Nov 2023 23:24:28 +0100
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Nikita Kiryushin <kiryushin@...ud.ru>
Cc:     Andy Gross <agross@...nel.org>,
        Bjorn Andersson <andersson@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...aro.org>,
        Stephen Boyd <sboyd@...eaurora.org>,
        Pramod Gurav <pramod.gurav@...rtplayin.com>,
        Guenter Roeck <linux@...ck-us.net>,
        linux-arm-msm@...r.kernel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, lvc-project@...uxtesting.org
Subject: Re: [PATCH] power: reset: msm: Process register_restart_handler()
 error

Hi,

On Wed, Nov 08, 2023 at 08:27:57PM +0300, Nikita Kiryushin wrote:
> If registering restart handler fails for msm-restart result is not checked.
> It may be irrelevant now (as stated in comment to register_restart_handler,
> the function currently always returns zero), but if the behavior changes
> in the future, an error at registration of handler will be silently skipped.
> 
> Add return error code and print error message too debug log in case of
> non-zero result of register_restart_handler.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 18a702e0de98 ("power: reset: use restart_notifier mechanism for
> msm-poweroff")
> 
> Signed-off-by: Nikita Kiryushin <kiryushin@...ud.ru>
> ---

If register_restart_handler fails, it might actually be a good idea
to continue and at least have a poweroff handler :)

>  drivers/power/reset/msm-poweroff.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/reset/msm-poweroff.c
> b/drivers/power/reset/msm-poweroff.c
> index b9a401bd280b..5877a1ba2778 100644
> --- a/drivers/power/reset/msm-poweroff.c
> +++ b/drivers/power/reset/msm-poweroff.c
> @@ -35,11 +35,16 @@ static void do_msm_poweroff(void)
>   static int msm_restart_probe(struct platform_device *pdev)
>  {
> +	int ret = -EINVAL;

no need to initialize, it's overwritten before being used.

>  	msm_ps_hold = devm_platform_ioremap_resource(pdev, 0);
>  	if (IS_ERR(msm_ps_hold))
>  		return PTR_ERR(msm_ps_hold);
>  -	register_restart_handler(&restart_nb);
> +	ret = register_restart_handler(&restart_nb);
> +	if (ret) {
> +		dev_err(&pdev->dev, "unable to register restart handler, %d\n", ret);
> +		return ret;

There is dev_err_probe() for this, but as mentioned above it's more
sensible not to fail here.

-- Sebastian

> +	}
>   	pm_power_off = do_msm_poweroff;
>  -- 2.34.1
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ