spi/spidev: handle integer wrap in spidev_message()
Subsystems (2)
PATCH 1/1 spi/spidev: handle integer wrap in spidev_message()
"k_tmp->len" and "total" are unsigned integers. The first message could be close to "bufsiz" (4096) and then the next message could be 4GB which would cause an integer overflow.
Signed-off-by Dan Carpenter <[email protected]>
---
I have not tested this.
drivers/spi/spidev.c +1 -1
@@ -241,7 +241,7 @@ static int spidev_message(struct spidev_data *spidev, k_tmp->len = u_tmp->len; total += k_tmp->len; -if (total > bufsiz) { +if (total > bufsiz || total < k_tmp->len) { status = -EMSGSIZE ; goto done; }