Skip to contentSkip to conversation

net/mlx5: SF, silence an uninitialized variable warning

PATCH Applied Dan Carpenter 3 participants 3 messages Nov 27, 2021 – Dec 2, 2021

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: SF, silence an uninitialized variable warning

This code sometimes calls mlx5_sf_hw_table_hwc_init() when "ext_base_id" is uninitialized. It's not used on that path, but it generates a static checker warning to pass uninitialized variables to another function. It may also generate runtime UBSan warnings depending on if the mlx5_sf_hw_table_hwc_init() function is inlined or not.

---
 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +1 -1
index 252d6017387d..17aa348989cb 100644
@@ -247,7 +247,7 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
 {
 	struct mlx5_sf_hw_table *table;
 	u16 max_ext_fn = 0;
-	u16 ext_base_id;
+	u16 ext_base_id = 0;
 	u16 max_fn = 0;
 	u16 base_id;
 	int err;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dan Carpenter

This code sometimes calls mlx5_sf_hw_table_hwc_init() when "ext_base_id" is uninitialized. It's not used on that path, but it generates a static checker warning to pass uninitialized variables to another function. It may also generate runtime UBSan warnings depending on if the mlx5_sf_hw_table_hwc_init() function is inlined or not.

---
 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,

maintainer Applied
#2 lore raw
Quoted 10 lines · Leon Romanovsky
Quoted 9 lines · Dan Carpenter

This code sometimes calls mlx5_sf_hw_table_hwc_init() when "ext_base_id"
is uninitialized.  It's not used on that path, but it generates a static
checker warning to pass uninitialized variables to another function.
It may also generate runtime UBSan  warnings depending on if the mlx5_sf_hw_table_hwc_init() function is inlined or not.

Quoted 7 lines
Quoted 4 lines

---
 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,

applied to net-next-mlx5.