net/atlantic: fix buffer overflow
authorPavel Belous <pavel.belous@aquantia.com>
Tue, 12 Mar 2019 15:24:57 +0000 (15:24 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 20 Mar 2019 17:15:42 +0000 (18:15 +0100)
Found by Coverity scan. This is a real memory corruption.
There is no need in extra RTE_ALIGN macros since the
request/result structures are 4-byte aligned by definition.

Coverity issue: 323518, 323520
Fixes: ce4e8d418097 ("net/atlantic: implement EEPROM get/set")
Cc: stable@dpdk.org
Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c

index 6841d9b..f90ccfe 100644 (file)
@@ -501,7 +501,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
        /* Write SMBUS request to cfg memory */
        err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
                                (u32 *)(void *)&request,
-                               RTE_ALIGN(sizeof(request), sizeof(u32)));
+                               sizeof(request) / sizeof(u32));
 
        if (err < 0)
                return err;
@@ -523,7 +523,7 @@ static int aq_fw2x_get_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
 
        err = hw_atl_utils_fw_downld_dwords(self, self->rpc_addr + sizeof(u32),
                        &result,
-                       RTE_ALIGN(sizeof(result), sizeof(u32)));
+                       sizeof(result) / sizeof(u32));
 
        if (err < 0)
                return err;
@@ -558,7 +558,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
        /* Write SMBUS request to cfg memory */
        err = hw_atl_utils_fw_upload_dwords(self, self->rpc_addr,
                                (u32 *)(void *)&request,
-                               RTE_ALIGN(sizeof(request), sizeof(u32)));
+                               sizeof(request) / sizeof(u32));
 
        if (err < 0)
                return err;
@@ -589,7 +589,7 @@ static int aq_fw2x_set_eeprom(struct aq_hw_s *self, u32 *data, u32 len)
        /* Read status of write operation */
        err = hw_atl_utils_fw_downld_dwords(self, self->rpc_addr + sizeof(u32),
                                &result,
-                               RTE_ALIGN(sizeof(result), sizeof(u32)));
+                               sizeof(result) / sizeof(u32));
 
        if (err < 0)
                return err;