net/atlantic: check EEPROM dev address validity
authorIgor Russkikh <igor.russkikh@aquantia.com>
Mon, 29 Apr 2019 08:20:19 +0000 (08:20 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 3 May 2019 16:45:23 +0000 (18:45 +0200)
Clients may not filling magic field, thus causing garbage
to be passed as a device address.

Limit that to maximum SMbus address.

Fixes: ce4e8d418097 ("net/atlantic: implement EEPROM get/set")
Cc: stable@dpdk.org
Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
drivers/net/atlantic/atl_ethdev.c

index 9881596..d757273 100644 (file)
@@ -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;