Skip to content

Commit 7dad1f7

Browse files
andy-shevopsiff
authored andcommitted
ACPI: battery: Check for error code from devm_mutex_init() call
[ Upstream commit 815daed ] Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check. Fixes: 0710c1c ("ACPI: battery: initialize mutexes through devm_ APIs") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://patch.msgid.link/20241030162754.2110946-1-andriy.shevchenko@linux.intel.com [ rjw: Added 2 empty code lines ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Stable-dep-of: 399dbca ("ACPI: battery: Add synchronization between interface updates") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 8f03b1bf2bcd60293c1c451d256b139f9d96e555)
1 parent caf89d7 commit 7dad1f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/acpi/battery.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,14 @@ static int acpi_battery_add(struct acpi_device *device)
12101210
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12111211
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12121212
device->driver_data = battery;
1213-
devm_mutex_init(&device->dev, &battery->lock);
1214-
devm_mutex_init(&device->dev, &battery->sysfs_lock);
1213+
result = devm_mutex_init(&device->dev, &battery->lock);
1214+
if (result)
1215+
return result;
1216+
1217+
result = devm_mutex_init(&device->dev, &battery->sysfs_lock);
1218+
if (result)
1219+
return result;
1220+
12151221
if (acpi_has_method(battery->device->handle, "_BIX"))
12161222
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
12171223

0 commit comments

Comments
 (0)