ACPI: Battery: Fix incorrect fallthrough in extract_package()
PATCH 1/1 ACPI: Battery: Fix incorrect fallthrough in extract_package()
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.
--- drivers/acpi/battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/battery.c +2 -1
@@ -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); - fallthrough; +break ;case ACPI_TYPE_STRING :strscpy (ptr, element->string.pointer, len);
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerQuoted 20 lines · Kaushlendra Kumar
Fix incorrect fallthrough behavior in the
ACPI_TYPE_BUFFERcase ofextract_package().The current code processes
ACPI_TYPE_BUFFERdata and then falls through to also process it asACPI_TYPE_STRINGdata, 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 <[email protected]>--- drivers/acpi/battery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/acpi/battery.c +0
-0
drivers/acpi/battery.c static int extract_package(struct acpi_battery *battery, · line 448
Quoted 4 lines
drivers/acpi/battery.c +1
-0@@ -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?
Quoted 7 lines
drivers/acpi/battery.c +1
-2-fallthrough ; +break ;case ACPI_TYPE_STRING :strscpy (ptr, element->string.pointer, len); --