Skip to contentSkip to conversation

net/mlx5: Bridge, fix uninitialized variable in mlx5_esw_bridge_port_changeupper()

PATCH In review Tim Gardner 3 participants 3 messages Aug 18, 2021 – Aug 19, 2021

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

PATCH 1/1 net/mlx5: Bridge, fix uninitialized variable in mlx5_esw_bridge_port_changeupper()

A recent change removed code that initialized the return code variable 'err'. It is now possible for mlx5_esw_bridge_port_changeupper() to return an error code using this uninitialized variable. Fix it by initializing to 0.

Addresses-Coverity: ("Uninitialized scalar variable (UNINIT)")

Cc Saeed Mahameed <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Vlad Buslov <[email protected]>
Cc Jianbo Liu <[email protected]>
Cc Mark Bloch <[email protected]>
Cc Roi Dayan <[email protected]>
Cc Vladimir Oltean <[email protected]>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c +1 -1
index 0c38c2e319be..c6435c69b7c4 100644
@@ -137,7 +137,7 @@ static int mlx5_esw_bridge_port_changeupper(struct notifier_block *nb, void *ptr
 	u16 vport_num, esw_owner_vhca_id;
 	struct netlink_ext_ack *extack;
 	int ifindex = upper->ifindex;
-	int err;
+	int err = 0;
 
 	if (!netif_is_bridge_master(upper))
 		return 0;
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Tim Gardner

A recent change removed code that initialized the return code variable 'err'. It is now possible for mlx5_esw_bridge_port_changeupper() to return an error code using this uninitialized variable. Fix it by initializing to 0.

Addresses-Coverity: ("Uninitialized scalar variable (UNINIT)")

Cc Saeed Mahameed <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Vlad Buslov <[email protected]>
Cc Jianbo Liu <[email protected]>
Cc Mark Bloch <[email protected]>
Cc Roi Dayan <[email protected]>
Cc Vladimir Oltean <[email protected]>
Quoted 1 line

---

Tim, thanks for fixing this!

Saeed, this is the second similar issue that I mentioned in my reply to Colin. Again, I've already submitted same patch internally and this one is as good as mine.

[...]

maintainer
#2 lore raw
Quoted 10 lines · Vlad Buslov
Quoted 8 lines · Tim Gardner

A recent change removed code that initialized the return code variable 'err'. It
is now possible for mlx5_esw_bridge_port_changeupper() to return an error code
using this uninitialized variable. Fix it by initializing to 0.

Addresses-Coverity: ("Uninitialized scalar variable (UNINIT)")

Quoted 12 lines
Quoted 4 lines
Cc Saeed Mahameed <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Quoted 8 lines

Just wondering, do we really need 12 inline CCs for fixing a poor coverity?

Quoted 10 lines
Quoted 2 lines

---

Tim, thanks for fixing this!

Saeed, this is the second similar issue that I mentioned in my reply to
Colin. Again, I've already submitted same patch internally and this one
is as good as mine.

I don't mind both patches are perfect.

Quoted 6 lines

[...]