lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jbhiGgw-vyGyQCTJe0bL67-c1d_qggkZC-vqnA8UsrbA@mail.gmail.com>
Date:   Wed, 6 Dec 2023 21:07:54 +0100
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Haoran Liu <liuhaoran14@....com>
Cc:     rafael@...nel.org, lenb@...nel.org, linux-acpi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [ACPI] fan_core: Add error handling for acpi_driver_data

On Wed, Nov 29, 2023 at 9:14 AM Haoran Liu <liuhaoran14@....com> wrote:
>
> This patch introduces error handling for the acpi_driver_data call
> in function acpi_fan_get_fif and acpi_fan_get_fps, within
> drivers/acpi/fan_core.c. Previously, there was no check for a null
> return from acpi_driver_data, which could lead to potential
> instability in scenarios where acpi_driver_data fails.

This needs to explain why/how it is possible for acpi_driver_data() to
return NULL in the 2 places modified by the patch.

> Signed-off-by: Haoran Liu <liuhaoran14@....com>
> ---
>  drivers/acpi/fan_core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c
> index 9dccbae9e8ea..f3228fb9c90f 100644
> --- a/drivers/acpi/fan_core.c
> +++ b/drivers/acpi/fan_core.c
> @@ -215,6 +215,13 @@ static int acpi_fan_get_fif(struct acpi_device *device)
>  {
>         struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>         struct acpi_fan *fan = acpi_driver_data(device);
> +
> +       if (!fan) {
> +               dev_err(&device->dev, "No ACPI fan data associated "
> +                       "with the device\n");
> +               return -EINVAL;
> +       }
> +
>         struct acpi_buffer format = { sizeof("NNNN"), "NNNN" };
>         u64 fields[4];
>         struct acpi_buffer fif = { sizeof(fields), fields };
> @@ -265,6 +272,12 @@ static int acpi_fan_speed_cmp(const void *a, const void *b)
>  static int acpi_fan_get_fps(struct acpi_device *device)
>  {
>         struct acpi_fan *fan = acpi_driver_data(device);
> +
> +       if (!fan) {
> +               dev_err(&device->dev, "Failed to retrieve ACPI fan data\n");
> +               return -ENODEV;
> +       }
> +
>         struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
>         union acpi_object *obj;
>         acpi_status status;
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ