[patch 2/2] tpm, st33zp24: potential underflow in st33zp24_recv()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Static checkers don't like the min_t() casting because "count" can be
negative when we cast it to int.  Fix the casting, and change the caller
so that "count" can't be negative.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index 03f2543..7712e31 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -350,7 +350,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
 		burstcnt = get_burstcount(chip);
 		if (burstcnt < 0)
 			return burstcnt;
-		len = min_t(int, burstcnt, count - size);
+		len = min_t(size_t, burstcnt, count - size);
 		ret = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_DATA_FIFO,
 					 buf + size, len);
 		if (ret < 0)
@@ -492,7 +492,7 @@ static int st33zp24_recv(struct tpm_chip *chip, unsigned char *buf,
 	}
 
 	expected = be32_to_cpu(*(__be32 *)(buf + 2));
-	if (expected > count) {
+	if (expected < TPM_HEADER_SIZE || expected > count) {
 		size = -EIO;
 		goto out;
 	}
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux