mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: ahs3@redhat.com, Jassi Brar <jassisinghbrar@gmail.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] mailbox: PCC: check for negative count for parse failure checking
Date: Wed, 30 May 2018 19:24:19 +0100	[thread overview]
Message-ID: <905b4bfb-9fca-a165-7911-61122281e6a4@canonical.com> (raw)
In-Reply-To: <0d780988-0e59-a3b7-a7c1-9e3f0d227412@redhat.com>

On 30/05/18 18:59, Al Stone wrote:
> On 05/30/2018 11:14 AM, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The function acpi_table_parse_enties_array can potentially return a
>> negative value if parsing fails. Currently the check on the return
>> is not checking for errors, so fix this by adding a -ve check too.
>>
>> Detected by CoverityScan, CID#1469477 ("Improper use of negative value")
>>
>> Fixes: 8f8027c5f935 ("mailbox: PCC: erroneous error message when parsing ACPI PCCT")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/mailbox/pcc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
>> index fc3c237daef2..87d67922020d 100644
>> --- a/drivers/mailbox/pcc.c
>> +++ b/drivers/mailbox/pcc.c
>> @@ -461,7 +461,7 @@ 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) {
>> +	if (count <= 0 || count > MAX_PCC_SUBSPACES) {
>>  		pr_warn("Invalid PCCT: %d PCC subspaces\n", count);
>>  		return -EINVAL;
>>  	}
>>
> 
> Yup, nice catch.  A little paranoid, but we like that in a kernel :).  Thanks.

If it can go wrong, it will go wrong, especially with firmware :-)
> 
> Reviewed-by: Al Stone <ahs3@redhat.com>
> 

  reply	other threads:[~2018-05-30 18:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 17:14 Colin King
2018-05-30 17:59 ` Al Stone
2018-05-30 18:24   ` Colin Ian King [this message]
2018-05-30 18:49     ` Al Stone
2018-05-30 19:21 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=905b4bfb-9fca-a165-7911-61122281e6a4@canonical.com \
    --to=colin.king@canonical.com \
    --cc=ahs3@redhat.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®