Skip to content

Commit f18ebc2

Browse files
Dan Carpenterrafaeljw
authored andcommitted
ACPI / sysfs: fix error code in get_status()
The problem with ornamental, do-nothing gotos is that they lead to "forgot to set the error code" bugs. We should be returning -EINVAL here but we don't. It leads to an uninitalized variable in counter_show(): drivers/acpi/sysfs.c:603 counter_show() error: uninitialized symbol 'status'. Fixes: 1c8fce2 (ACPI: introduce drivers/acpi/sysfs.c) Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a508d95 commit f18ebc2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/acpi/sysfs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,23 +555,22 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
555555
static int get_status(u32 index, acpi_event_status *status,
556556
acpi_handle *handle)
557557
{
558-
int result = 0;
558+
int result;
559559

560560
if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
561-
goto end;
561+
return -EINVAL;
562562

563563
if (index < num_gpes) {
564564
result = acpi_get_gpe_device(index, handle);
565565
if (result) {
566566
ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
567567
"Invalid GPE 0x%x", index));
568-
goto end;
568+
return result;
569569
}
570570
result = acpi_get_gpe_status(*handle, index, status);
571571
} else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
572572
result = acpi_get_event_status(index - num_gpes, status);
573573

574-
end:
575574
return result;
576575
}
577576

0 commit comments

Comments
 (0)