public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
	Nayna Jain <nayna@linux.vnet.ibm.com>,
	Marcel Selhorst <tpmdd@selhorst.net>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	tpmdd-devel@lists.sourceforge.net,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] tpm: silence an array overflow warning
Date: Fri, 03 Feb 2017 18:11:20 +0000	[thread overview]
Message-ID: <20170203181120.d3r7ab4twbvelwmi@intel.com> (raw)
In-Reply-To: <20170203103040.GA5467@mwanda>

On Fri, Feb 03, 2017 at 01:30:40PM +0300, Dan Carpenter wrote:
> We should check that we're within bounds first before checking that
> "chip->active_banks[i] != TPM2_ALG_ERROR" so I've re-ordered the two
> checks.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thank you, good catch! Do you mind if I squash this.

/Jarkko

> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 423938e8570f..087748b8264f 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -800,8 +800,8 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
>  	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
>  		memset(digest_list, 0, sizeof(digest_list));
>  
> -		for (i = 0; chip->active_banks[i] != TPM2_ALG_ERROR &&
> -		     i < ARRAY_SIZE(chip->active_banks); i++) {
> +		for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
> +			    chip->active_banks[i] != TPM2_ALG_ERROR; i++) {
>  			digest_list[i].alg_id = chip->active_banks[i];
>  			memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE);
>  			count++;

  reply	other threads:[~2017-02-03 18:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 10:30 [patch] tpm: silence an array overflow warning Dan Carpenter
2017-02-03 18:11 ` Jarkko Sakkinen [this message]
2017-02-06  9:20   ` Dan Carpenter
2017-02-06 14:15     ` Jarkko Sakkinen

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=20170203181120.d3r7ab4twbvelwmi@intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=nayna@linux.vnet.ibm.com \
    --cc=peterhuewe@gmx.de \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    /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