]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ACPI: sysfs: Prevent get_status() from returning acpi_status
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 Mar 2019 09:30:29 +0000 (10:30 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 Mar 2019 09:34:58 +0000 (10:34 +0100)
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>
drivers/acpi/sysfs.c

index 41324f0b1bee26b73a55ddc027fb8f52928a31a5..fa76f5e41b5ca419978c804e8df8d8b2b714e329 100644 (file)
@@ -648,26 +648,29 @@ static void acpi_global_event_handler(u32 event_type, acpi_handle device,
        }
 }
 
-static int get_status(u32 index, acpi_event_status *status,
+static int get_status(u32 index, acpi_event_status *ret,
                      acpi_handle *handle)
 {
-       int result;
+       acpi_status status;
 
        if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
                return -EINVAL;
 
        if (index < num_gpes) {
-               result = acpi_get_gpe_device(index, handle);
-               if (result) {
+               status = acpi_get_gpe_device(index, handle);
+               if (ACPI_FAILURE(status)) {
                        ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
                                        "Invalid GPE 0x%x", index));
-                       return result;
+                       return -ENXIO;
                }
-               result = acpi_get_gpe_status(*handle, index, status);
-       } else if (index < (num_gpes + ACPI_NUM_FIXED_EVENTS))
-               result = acpi_get_event_status(index - num_gpes, status);
+               status = acpi_get_gpe_status(*handle, index, ret);
+       } else {
+               status = acpi_get_event_status(index - num_gpes, ret);
+       }
+       if (ACPI_FAILURE(status))
+               return -EIO;
 
-       return result;
+       return 0;
 }
 
 static ssize_t counter_show(struct kobject *kobj,