Skip to content

Commit 91507d2

Browse files
Wer-Wolfrafaeljw
authored andcommitted
ACPI: battery: Increase maximum string length
On the Dell Inspiron 3505, the battery model name is represented as a hex string containing seven numbers, causing it to be larger than the current maximum string length (32). Increase this length to 64 to avoid truncating the string in such cases. Also introduce a common define for the length. Signed-off-by: Armin Wolf <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a1a32de commit 91507d2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/acpi/battery.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#define ACPI_BATTERY_STATE_CHARGING 0x2
4343
#define ACPI_BATTERY_STATE_CRITICAL 0x4
4444

45+
#define MAX_STRING_LENGTH 64
46+
4547
MODULE_AUTHOR("Paul Diefenbaugh");
4648
MODULE_AUTHOR("Alexey Starikovskiy <[email protected]>");
4749
MODULE_DESCRIPTION("ACPI Battery Driver");
@@ -118,10 +120,10 @@ struct acpi_battery {
118120
int capacity_granularity_1;
119121
int capacity_granularity_2;
120122
int alarm;
121-
char model_number[32];
122-
char serial_number[32];
123-
char type[32];
124-
char oem_info[32];
123+
char model_number[MAX_STRING_LENGTH];
124+
char serial_number[MAX_STRING_LENGTH];
125+
char type[MAX_STRING_LENGTH];
126+
char oem_info[MAX_STRING_LENGTH];
125127
int state;
126128
int power_unit;
127129
unsigned long flags;
@@ -437,7 +439,7 @@ static int extract_package(struct acpi_battery *battery,
437439
element = &package->package.elements[i];
438440
if (offsets[i].mode) {
439441
u8 *ptr = (u8 *)battery + offsets[i].offset;
440-
u32 len = 32;
442+
u32 len = MAX_STRING_LENGTH;
441443

442444
switch (element->type) {
443445
case ACPI_TYPE_BUFFER:

0 commit comments

Comments
 (0)