[5/6] net/bnxt: add integer underflow check
diff mbox series

Message ID 20200303175938.14292-6-stephen@networkplumber.org
State Changes Requested, archived
Delegated to: Ajit Khaparde
Headers show
  • net/bnxt: bounds checking patches
Related show


Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger March 3, 2020, 5:59 p.m. UTC
If a request to read a small value is passed to nvram reader
it would underflow.

Reported-by: Christopher Ertl <Christopher.Ertl@microsoft.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
 drivers/net/bnxt/bnxt_hwrm.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox series

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 6beb215d604f..d878320aa110 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3859,6 +3859,9 @@  int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data)
 	*data++ = dir_entries;
 	*data++ = entry_length;
+	if (len <= 2)
+		return -EINVAL;
 	len -= 2;
 	memset(data, 0xff, len);