Skip to content

Commit d4e8378

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/x86: dell-ddv: Fix taking the psy->extensions_sem lock twice
Calling power_supply_get_property() inside dell_wmi_ddv_battery_translate() can cause a deadlock since this function is also being called from the power supply extension code, in which case psy->extensions_sem is already being held. Fix this by using the new power_supply_get_property_direct() function to ignore any power supply extensions when retrieving the battery serial number. Tested on a Dell Inspiron 3505. Reported-by: Hans de Goede <[email protected]> Fixes: 058de16 ("platform/x86: dell-ddv: Implement the battery matching algorithm") Signed-off-by: Armin Wolf <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent a5f3542 commit d4e8378

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/platform/x86/dell/dell-wmi-ddv.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,13 @@ static int dell_wmi_ddv_battery_translate(struct dell_wmi_ddv_data *data,
689689

690690
dev_dbg(&data->wdev->dev, "Translation cache miss\n");
691691

692-
/* Perform a translation between a ACPI battery and a battery index */
693-
694-
ret = power_supply_get_property(battery, POWER_SUPPLY_PROP_SERIAL_NUMBER, &val);
692+
/*
693+
* Perform a translation between a ACPI battery and a battery index.
694+
* We have to use power_supply_get_property_direct() here because this
695+
* function will also get called from the callbacks of the power supply
696+
* extension.
697+
*/
698+
ret = power_supply_get_property_direct(battery, POWER_SUPPLY_PROP_SERIAL_NUMBER, &val);
695699
if (ret < 0)
696700
return ret;
697701

0 commit comments

Comments
 (0)