Skip to content

Commit 3fd16d7

Browse files
committed
ACPI: sysfs: Prevent get_status() from returning acpi_status
The return value of get_status() is passed to user space on errors, so it should not return acpi_status values then. Make it return error values that are meaningful for user space instead. This also makes a Clang warning regarding the initialization of a local variable in get_status() go away. Reported-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d276709 commit 3fd16d7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

drivers/acpi/sysfs.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -648,26 +648,29 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
648648
}
649649
}
650650

651-
static int get_status(u32 index, acpi_event_status *status,
651+
static int get_status(u32 index, acpi_event_status *ret,
652652
acpi_handle *handle)
653653
{
654-
int result;
654+
acpi_status status;
655655

656656
if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
657657
return -EINVAL;
658658

659659
if (index < num_gpes) {
660-
result = acpi_get_gpe_device(index, handle);
661-
if (result) {
660+
status = acpi_get_gpe_device(index, handle);
661+
if (ACPI_FAILURE(status)) {
662662
ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
663663
"Invalid GPE 0x%x", index));
664-
return result;
664+
return -ENXIO;
665665
}
666-
result = acpi_get_gpe_status(*handle, index, status);
667-
} else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
668-
result = acpi_get_event_status(index - num_gpes, status);
666+
status = acpi_get_gpe_status(*handle, index, ret);
667+
} else {
668+
status = acpi_get_event_status(index - num_gpes, ret);
669+
}
670+
if (ACPI_FAILURE(status))
671+
return -EIO;
669672

670-
return result;
673+
return 0;
671674
}
672675

673676
static ssize_t counter_show(struct kobject *kobj,

0 commit comments

Comments
 (0)