Skip to content

Commit e424fb8

Browse files
xiwMatthew Garrett
authored andcommitted
panasonic-laptop: avoid overflow in acpi_pcc_hotkey_add()
num_sifr could go negative since acpi_pcc_get_sqty() returns -EINVAL on error. Then it could bypass the sanity check (num_sifr > 255). The subsequent call to kzalloc() would allocate a small buffer, leading to a memory corruption. Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
1 parent 461e743 commit e424fb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/platform/x86/panasonic-laptop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
562562

563563
num_sifr = acpi_pcc_get_sqty(device);
564564

565-
if (num_sifr > 255) {
566-
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "num_sifr too large"));
565+
if (num_sifr < 0 || num_sifr > 255) {
566+
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "num_sifr out of range"));
567567
return -ENODEV;
568568
}
569569

0 commit comments

Comments
 (0)