mailbox: PCC: handle parse error
PATCH 1/1 mailbox: PCC: handle parse error
acpi_pcc_probe calls acpi_table_parse_entries_array but fails to check for an error return. This in turn can result in calling kcalloc with a negative count as well as emitting the following misleading erorr message:
[ 2.642015] Could not allocate space for PCC mbox channels
--- drivers/mailbox/pcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/mailbox/pcc.c +5 -2
@@ -461,8 +461,11 @@ static int __init acpi_pcc_probe(void) count =acpi_table_parse_entries_array (ACPI_SIG_PCCT ,sizeof (struct acpi_table_pcct ), proc,ACPI_PCCT_TYPE_RESERVED ,MAX_PCC_SUBSPACES ); -if (count ==0 || count >MAX_PCC_SUBSPACES ) { -pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count); +if (count <=0 || count >MAX_PCC_SUBSPACES ) { +if (count <0 ) +pr_warn ("Error parsing PCC subspaces from PCCT\n" ); +else +pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count);return -EINVAL ; }
Signature · 1 line
1.8.3.1
Quoted 25 lines · David Arcari
acpi_pcc_probecallsacpi_table_parse_entries_arraybut fails to check for an error return. This in turn can result in calling kcalloc with a negative count as well as emitting the following misleading erorr message:[ 2.642015] Could not allocate space for PCC mbox channelsFixes 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")Signed-off-by David Arcari <[email protected]>Cc Al Stone <[email protected]>Cc Jassi Brar <[email protected]>--- drivers/mailbox/pcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/mailbox/pcc.c +0
-0@@ -461,8 +461,11 @@ static int __init acpi_pcc_probe(void) count =acpi_table_parse_entries_array (ACPI_SIG_PCCT ,sizeof (struct acpi_table_pcct ), proc,ACPI_PCCT_TYPE_RESERVED ,MAX_PCC_SUBSPACES );
drivers/mailbox/pcc.c static int __init acpi_pcc_probe(void) · line 471
Quoted 10 lines
drivers/mailbox/pcc.c +5
-2-if (count ==0 || count >MAX_PCC_SUBSPACES ) { -pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count); +if (count <=0 || count >MAX_PCC_SUBSPACES ) { +if (count <0 ) +pr_warn ("Error parsing PCC subspaces from PCCT\n" ); +else +pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count);return -EINVAL ; }
Thanks, David. Nice catch.
Signature · 8 lines
ciao, al ----------------------------------- Al Stone Software Engineer Red Hat, Inc. [email protected] -----------------------------------
Quoted 39 lines · CEST Al Stone
Quoted 25 lines · David Arcari
acpi_pcc_probecallsacpi_table_parse_entries_arraybut fails to check for an error return. This in turn can result in calling kcalloc with a negative count as well as emitting the following misleading erorr message:[ 2.642015] Could not allocate space for PCC mbox channelsFixes 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")Signed-off-by David Arcari <[email protected]>Cc Al Stone <[email protected]>Cc Jassi Brar <[email protected]>--- drivers/mailbox/pcc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/mailbox/pcc.c +0
-0@@ -461,8 +461,11 @@ static int __init acpi_pcc_probe(void) count =acpi_table_parse_entries_array (ACPI_SIG_PCCT ,sizeof (struct acpi_table_pcct ), proc,ACPI_PCCT_TYPE_RESERVED ,MAX_PCC_SUBSPACES );drivers/mailbox/pcc.c static int __init acpi_pcc_probe(void) · line 471
Quoted 10 lines
drivers/mailbox/pcc.c +5
-2-if (count ==0 || count >MAX_PCC_SUBSPACES ) { -pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count); +if (count <=0 || count >MAX_PCC_SUBSPACES ) { +if (count <0 ) +pr_warn ("Error parsing PCC subspaces from PCCT\n" ); +else +pr_warn ("Invalid PCCT: %d PCC subspaces\n" , count);return -EINVAL ; }Thanks, David. Nice catch.
Quoted 1 line
Reviewed-by Al Stone <[email protected]>
Patch applied, thanks!