linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailbox: PCC: handle parse error
@ 2018-08-27 19:19 David Arcari
  2018-08-27 20:55 ` Al Stone
  0 siblings, 1 reply; 3+ messages in thread
From: David Arcari @ 2018-08-27 19:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-acpi, David Arcari, Al Stone, Jassi Brar

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

Fixes: 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")

Signed-off-by: David Arcari <darcari@redhat.com>
Cc: Al Stone <ahs3@redhat.com>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
---
 drivers/mailbox/pcc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 311e91b..256f18b 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -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;
 	}
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mailbox: PCC: handle parse error
  2018-08-27 19:19 [PATCH] mailbox: PCC: handle parse error David Arcari
@ 2018-08-27 20:55 ` Al Stone
  2018-09-14  8:41   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Al Stone @ 2018-08-27 20:55 UTC (permalink / raw)
  To: David Arcari, linux-kernel; +Cc: linux-acpi, Jassi Brar

On 08/27/2018 01:19 PM, David Arcari wrote:
> 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
> 
> Fixes: 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Al Stone <ahs3@redhat.com>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
> ---
>  drivers/mailbox/pcc.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
> index 311e91b..256f18b 100644
> --- a/drivers/mailbox/pcc.c
> +++ b/drivers/mailbox/pcc.c
> @@ -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;
>  	}
>  
> 

Thanks, David.  Nice catch.

Reviewed-by: Al Stone <ahs3@redhat.com>

-- 
ciao,
al
-----------------------------------
Al Stone
Software Engineer
Red Hat, Inc.
ahs3@redhat.com
-----------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mailbox: PCC: handle parse error
  2018-08-27 20:55 ` Al Stone
@ 2018-09-14  8:41   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2018-09-14  8:41 UTC (permalink / raw)
  To: ahs3, David Arcari; +Cc: linux-kernel, linux-acpi, Jassi Brar

On Monday, August 27, 2018 10:55:41 PM CEST Al Stone wrote:
> On 08/27/2018 01:19 PM, David Arcari wrote:
> > 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
> > 
> > Fixes: 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")
> > 
> > Signed-off-by: David Arcari <darcari@redhat.com>
> > Cc: Al Stone <ahs3@redhat.com>
> > Cc: Jassi Brar <jassisinghbrar@gmail.com>
> > ---
> >  drivers/mailbox/pcc.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
> > index 311e91b..256f18b 100644
> > --- a/drivers/mailbox/pcc.c
> > +++ b/drivers/mailbox/pcc.c
> > @@ -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;
> >  	}
> >  
> > 
> 
> Thanks, David.  Nice catch.
> 
> Reviewed-by: Al Stone <ahs3@redhat.com>

Patch applied, thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-14  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-27 19:19 [PATCH] mailbox: PCC: handle parse error David Arcari
2018-08-27 20:55 ` Al Stone
2018-09-14  8:41   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).