[04/10] net/atlantic: fix buffer overflow

Message ID 98bd8e1bae4b53c5d2231faf8ac45edc44a81a7c.1551528549.git.igor.russkikh@aquantia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/atlantic: bugfixes and code cleanup |

Checks

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

Commit Message

Igor Russkikh March 2, 2019, 12:10 p.m. UTC
  From: Pavel Belous <Pavel.Belous@aquantia.com>

Found by Coverity

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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 6841d9bce..a155d4aab 100644
--- a/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -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)));
+				RTE_ALIGN(sizeof(request) / sizeof(u32), 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)));
+			RTE_ALIGN(sizeof(result) / sizeof(u32), 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)));
+				RTE_ALIGN(sizeof(request) / sizeof(u32), 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)));
+				RTE_ALIGN(sizeof(result) / sizeof(u32), sizeof(u32)));
 
 	if (err < 0)
 		return err;