Skip to content

Commit 815daed

Browse files
andy-shevrafaeljw
authored andcommitted
ACPI: battery: Check for error code from devm_mutex_init() call
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>
1 parent a56fdd8 commit 815daed

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
@@ -1225,8 +1225,14 @@ static int acpi_battery_add(struct acpi_device *device)
12251225
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12261226
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12271227
device->driver_data = battery;
1228-
devm_mutex_init(&device->dev, &battery->lock);
1229-
devm_mutex_init(&device->dev, &battery->sysfs_lock);
1228+
result = devm_mutex_init(&device->dev, &battery->lock);
1229+
if (result)
1230+
return result;
1231+
1232+
result = devm_mutex_init(&device->dev, &battery->sysfs_lock);
1233+
if (result)
1234+
return result;
1235+
12301236
if (acpi_has_method(battery->device->handle, "_BIX"))
12311237
set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
12321238

0 commit comments

Comments
 (0)