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: <20220609221224.t5k7i4w4dfjza5xc@mercury.elektranox.org>
Date:   Fri, 10 Jun 2022 00:12:24 +0200
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Manaf Meethalavalappu Pallikunhi <quic_manafm@...cinc.com>
Cc:     linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        gregkh@...gle.com,
        Subbaraman Narayanamurthy <quic_subbaram@...cinc.com>
Subject: Re: [RESEND 1/2] power_supply: Register cooling device outside of
 probe

Hi,

On Wed, Jun 01, 2022 at 12:00:53AM +0530, Manaf Meethalavalappu Pallikunhi wrote:
> Registering the cooling device from the probe can result in the
> execution of get_property() function before it gets initialized.
> 
> To avoid this, register the cooling device from a workqueue
> instead of registering in the probe.
> 
> Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@...cinc.com>
> ---

This removes error handling from the psy_register_cooler() call, so
it introduces a new potential problem. If power_supply_get_property()
is called to early -EAGAIN is returned. So can you elaborate the problem
that you are seeing with the current code?

-- Sebastian

>  drivers/power/supply/power_supply_core.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 385814a14a0a..74623c4977db 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -132,6 +132,7 @@ void power_supply_changed(struct power_supply *psy)
>  }
>  EXPORT_SYMBOL_GPL(power_supply_changed);
>  
> +static int psy_register_cooler(struct power_supply *psy);
>  /*
>   * Notify that power supply was registered after parent finished the probing.
>   *
> @@ -139,6 +140,8 @@ EXPORT_SYMBOL_GPL(power_supply_changed);
>   * calling power_supply_changed() directly from power_supply_register()
>   * would lead to execution of get_property() function provided by the driver
>   * too early - before the probe ends.
> + * Also, registering cooling device from the probe will execute the
> + * get_property() function. So register the cooling device after the probe.
>   *
>   * Avoid that by waiting on parent's mutex.
>   */
> @@ -156,6 +159,7 @@ static void power_supply_deferred_register_work(struct work_struct *work)
>  	}
>  
>  	power_supply_changed(psy);
> +	psy_register_cooler(psy);
>  
>  	if (psy->dev.parent)
>  		mutex_unlock(&psy->dev.parent->mutex);
> @@ -1261,10 +1265,6 @@ __power_supply_register(struct device *parent,
>  	if (rc)
>  		goto register_thermal_failed;
>  
> -	rc = psy_register_cooler(psy);
> -	if (rc)
> -		goto register_cooler_failed;
> -
>  	rc = power_supply_create_triggers(psy);
>  	if (rc)
>  		goto create_triggers_failed;
> @@ -1294,8 +1294,6 @@ __power_supply_register(struct device *parent,
>  add_hwmon_sysfs_failed:
>  	power_supply_remove_triggers(psy);
>  create_triggers_failed:
> -	psy_unregister_cooler(psy);
> -register_cooler_failed:
>  	psy_unregister_thermal(psy);
>  register_thermal_failed:
>  	device_del(dev);

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