Re: [PATCH] platform/x86: asus-wireless: Fix uninitialized symbol usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 30, 2018 at 1:12 AM, João Paulo Rechi Vita
<jprvita@xxxxxxxxx> wrote:
> From: João Paulo Rechi Vita <jprvita@xxxxxxxxx>
>
> 'ret' will not be initialized if acpi_evaluate_integer() returns through
> an error path, so it should not be used in this case. This fixes the
> following Smatch static analyser error:
>
>  drivers/platform/x86/asus-wireless.c:76 asus_wireless_method() error:
>                                                      uninitialized symbol 'ret'.
>

Pushed to my review and testing queue, thanks!


> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Signed-off-by: João Paulo Rechi Vita <jprvita@xxxxxxxxxxxx>
> ---
>  drivers/platform/x86/asus-wireless.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
> index 0e9f5ec13474..7458f7602d5e 100644
> --- a/drivers/platform/x86/asus-wireless.c
> +++ b/drivers/platform/x86/asus-wireless.c
> @@ -52,13 +52,12 @@ static const struct acpi_device_id device_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(acpi, device_ids);
>
> -static u64 asus_wireless_method(acpi_handle handle, const char *method,
> -                               int param)
> +static acpi_status asus_wireless_method(acpi_handle handle, const char *method,
> +                                       int param, u64 *ret)
>  {
>         struct acpi_object_list p;
>         union acpi_object obj;
>         acpi_status s;
> -       u64 ret;
>
>         acpi_handle_debug(handle, "Evaluating method %s, parameter %#x\n",
>                           method, param);
> @@ -67,24 +66,27 @@ static u64 asus_wireless_method(acpi_handle handle, const char *method,
>         p.count = 1;
>         p.pointer = &obj;
>
> -       s = acpi_evaluate_integer(handle, (acpi_string) method, &p, &ret);
> +       s = acpi_evaluate_integer(handle, (acpi_string) method, &p, ret);
>         if (ACPI_FAILURE(s))
>                 acpi_handle_err(handle,
>                                 "Failed to eval method %s, param %#x (%d)\n",
>                                 method, param, s);
> -       acpi_handle_debug(handle, "%s returned %#llx\n", method, ret);
> -       return ret;
> +       else
> +               acpi_handle_debug(handle, "%s returned %#llx\n", method, *ret);
> +
> +       return s;
>  }
>
>  static enum led_brightness led_state_get(struct led_classdev *led)
>  {
>         struct asus_wireless_data *data;
> -       int s;
> +       acpi_status s;
> +       u64 ret;
>
>         data = container_of(led, struct asus_wireless_data, led);
>         s = asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
> -                                data->hswc_params->status);
> -       if (s == data->hswc_params->on)
> +                                data->hswc_params->status, &ret);
> +       if (ACPI_SUCCESS(s) && ret == data->hswc_params->on)
>                 return LED_FULL;
>         return LED_OFF;
>  }
> @@ -92,10 +94,11 @@ static enum led_brightness led_state_get(struct led_classdev *led)
>  static void led_state_update(struct work_struct *work)
>  {
>         struct asus_wireless_data *data;
> +       u64 ret;
>
>         data = container_of(work, struct asus_wireless_data, led_work);
>         asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
> -                            data->led_state);
> +                            data->led_state, &ret);
>  }
>
>  static void led_state_set(struct led_classdev *led, enum led_brightness value)
> --
> 2.18.0
>



-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux