Skip to content

Commit 172066c

Browse files
andrzejtpdlezcano
authored andcommitted
acpi: thermal: Fix error handling in the register function
The acpi_thermal_register_thermal_zone() is missing any error handling. This needs to be fixed. Signed-off-by: Andrzej Pietrasiewicz <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]> Reviewed-by: Amit Kucheria <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9ebcfad commit 172066c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/acpi/thermal.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,23 +901,35 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
901901
result = sysfs_create_link(&tz->device->dev.kobj,
902902
&tz->thermal_zone->device.kobj, "thermal_zone");
903903
if (result)
904-
return result;
904+
goto unregister_tzd;
905905

906906
result = sysfs_create_link(&tz->thermal_zone->device.kobj,
907907
&tz->device->dev.kobj, "device");
908908
if (result)
909-
return result;
909+
goto remove_tz_link;
910910

911911
status = acpi_bus_attach_private_data(tz->device->handle,
912912
tz->thermal_zone);
913-
if (ACPI_FAILURE(status))
914-
return -ENODEV;
913+
if (ACPI_FAILURE(status)) {
914+
result = -ENODEV;
915+
goto remove_dev_link;
916+
}
915917

916918
tz->tz_enabled = 1;
917919

918920
dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
919921
tz->thermal_zone->id);
922+
920923
return 0;
924+
925+
remove_dev_link:
926+
sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
927+
remove_tz_link:
928+
sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
929+
unregister_tzd:
930+
thermal_zone_device_unregister(tz->thermal_zone);
931+
932+
return result;
921933
}
922934

923935
static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)

0 commit comments

Comments
 (0)