diff mbox series

[06/11] net/atlantic: validity check for eeprom dev address

Message ID 5fe871b21ba5c4c75e8384d71cd5effbfccb8ddf.1556525874.git.igor.russkikh@aquantia.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series Aquantia atlantic bugfixes | expand

Checks

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

Commit Message

Igor Russkikh April 29, 2019, 8:20 a.m. UTC
Clients may not fillin magic field, thus causing garbage
to be passed as a device addr.

Limit that to maximum SMbus address.

Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
---
 drivers/net/atlantic/atl_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 8a177ea5b4a3..485ef159eb05 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -1433,6 +1433,9 @@  int atl_dev_get_eeprom(struct rte_eth_dev *dev,
 	    eeprom->data == NULL)
 		return -EINVAL;
 
+	if (eeprom->magic > 0x7F)
+		return -EINVAL;
+
 	if (eeprom->magic)
 		dev_addr = eeprom->magic;
 
@@ -1453,6 +1456,9 @@  int atl_dev_set_eeprom(struct rte_eth_dev *dev,
 	    eeprom->data == NULL)
 		return -EINVAL;
 
+	if (eeprom->magic > 0x7F)
+		return -EINVAL;
+
 	if (eeprom->magic)
 		dev_addr = eeprom->magic;