Re: [PATCH] ACPI: Battery: Fix incorrect fallthrough in extract_package()

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

 



On Wed, Aug 20, 2025 at 6:44 AM Kaushlendra Kumar
<kaushlendra.kumar@xxxxxxxxx> wrote:
>
> Fix incorrect fallthrough behavior in the ACPI_TYPE_BUFFER case of
> extract_package().
>
> The current code processes ACPI_TYPE_BUFFER data and then falls through
> to also process it as ACPI_TYPE_STRING data, which is incorrect. The
> buffer case should copy the buffer data and then break, not fall through
> to the string handling code. This ensures that buffer and string types
> are handled correctly and independently in the switch statement.
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@xxxxxxxxx>
> ---
>  drivers/acpi/battery.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 6905b56bf3e4..18fc5d828e70 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -445,8 +445,9 @@ static int extract_package(struct acpi_battery *battery,
>                         case ACPI_TYPE_BUFFER:
>                                 if (len > element->buffer.length + 1)
>                                         len = element->buffer.length + 1;
> +                               strscpy(ptr, element->buffer.pointer, len);

Why do you think that duplicating code is a good idea?

>
> -                               fallthrough;
> +                               break;
>                         case ACPI_TYPE_STRING:
>                                 strscpy(ptr, element->string.pointer, len);
>
> --





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux