]> git.ipfire.org Git - thirdparty/u-boot.git/commit
tpm: sandbox: fix wrong check on pcr_map
authorMiquel Raynal <miquel.raynal@bootlin.com>
Sun, 5 Aug 2018 16:53:06 +0000 (18:53 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 13 Aug 2018 18:04:04 +0000 (14:04 -0400)
commitfd973ca6969e556bfeb74e69c5a6867785c9ea5c
treee013a1108cfa3ae14d3c27741a60b86da1efad55
parentce18baf911340f8adbf2b63cd910a3d3346135e5
tpm: sandbox: fix wrong check on pcr_map

The second check on pcr_map in sandbox_tpm2_xfer() is wrong. It should
check for pcr_map not being empty. Instead, it is a pure copy/paste of
the first check which is redundant.

This has been found thanks to a Coverity Scan report:

    CID 183370:  Memory - illegal accesses  (UNINIT)
    Using uninitialized value "pcr_index".
        put_unaligned_be32(tpm->pcr_extensions[pcr_index], recv);

This is because pcr_index is initialized only if the user input is
correct, ie. at least one valid bit is set in pcr_map.

Fix the second check and also initialize pcr_index to 0 (which is
harmless in case of error) to make Coverity Scan happy.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/tpm/tpm2_tis_sandbox.c