All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin King <colin.king@canonical.com>,
	Jerry Snitselaar <jsnitsel@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-efi@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
Date: Tue, 08 Oct 2019 11:46:37 +0000	[thread overview]
Message-ID: <20191008114559.GD25098@kadam> (raw)
In-Reply-To: <20191008100153.8499-1-colin.king@canonical.com>

On Tue, Oct 08, 2019 at 11:01:53AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for tbl_size being less than zero is always false
> because tbl_size is unsigned. Fix this by making it a signed int.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/firmware/efi/tpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
> index 703469c1ab8e..ebd7977653a8 100644
> --- a/drivers/firmware/efi/tpm.c
> +++ b/drivers/firmware/efi/tpm.c
> @@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
>  {
>  	struct linux_efi_tpm_eventlog *log_tbl;
>  	struct efi_tcg2_final_events_table *final_tbl;
> -	unsigned int tbl_size;
> +	int tbl_size;
>  	int ret = 0;


Do we need to do a "ret = tbl_size;"?  Currently we return success.
It's a pitty that tpm2_calc_event_log_size() returns a -1 instead of
-EINVAL.

regards,
dan carpenter

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Colin King <colin.king@canonical.com>,
	Jerry Snitselaar <jsnitsel@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-efi@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero
Date: Tue, 8 Oct 2019 14:46:37 +0300	[thread overview]
Message-ID: <20191008114559.GD25098@kadam> (raw)
In-Reply-To: <20191008100153.8499-1-colin.king@canonical.com>

On Tue, Oct 08, 2019 at 11:01:53AM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for tbl_size being less than zero is always false
> because tbl_size is unsigned. Fix this by making it a signed int.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: e658c82be556 ("efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/firmware/efi/tpm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
> index 703469c1ab8e..ebd7977653a8 100644
> --- a/drivers/firmware/efi/tpm.c
> +++ b/drivers/firmware/efi/tpm.c
> @@ -40,7 +40,7 @@ int __init efi_tpm_eventlog_init(void)
>  {
>  	struct linux_efi_tpm_eventlog *log_tbl;
>  	struct efi_tcg2_final_events_table *final_tbl;
> -	unsigned int tbl_size;
> +	int tbl_size;
>  	int ret = 0;


Do we need to do a "ret = tbl_size;"?  Currently we return success.
It's a pitty that tpm2_calc_event_log_size() returns a -1 instead of
-EINVAL.

regards,
dan carpenter


  parent reply	other threads:[~2019-10-08 11:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 10:01 [PATCH][next] efi/tpm: fix sanity check of unsigned tbl_size being less than zero Colin King
2019-10-08 10:01 ` Colin King
2019-10-08 11:05 ` [tip: efi/urgent] efi/tpm: Fix " tip-bot2 for Colin Ian King
2019-10-08 11:05   ` tip-bot2 for Colin Ian King
2019-10-08 11:46 ` Dan Carpenter [this message]
2019-10-08 11:46   ` [PATCH][next] efi/tpm: fix " Dan Carpenter
2019-10-08 16:15   ` Jerry Snitselaar
2019-10-08 16:15     ` Jerry Snitselaar
2019-10-08 16:24     ` Colin Ian King
2019-10-08 16:24       ` Colin Ian King
2019-10-08 15:47 ` Jerry Snitselaar
2019-10-08 15:47   ` Jerry Snitselaar

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=20191008114559.GD25098@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=colin.king@canonical.com \
    --cc=jsnitsel@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.