2021-08-18 15:54:20

by Tim Gardner

[permalink] [raw]
Subject: [PATCH][linux-next] 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]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Tim Gardner <[email protected]>
---
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
index 0c38c2e319be..c6435c69b7c4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
@@ -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;
--
2.33.0


2021-08-18 16:49:05

by Vlad Buslov

[permalink] [raw]
Subject: Re: [PATCH][linux-next] net/mlx5: Bridge, fix uninitialized variable in mlx5_esw_bridge_port_changeupper()

On Wed 18 Aug 2021 at 18:52, Tim Gardner <[email protected]> wrote:
> 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]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Tim Gardner <[email protected]>
> ---

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.

Reviewed-by: Vlad Buslov <[email protected]>

[...]


2021-08-19 07:53:38

by Saeed Mahameed

[permalink] [raw]
Subject: Re: [PATCH][linux-next] net/mlx5: Bridge, fix uninitialized variable in mlx5_esw_bridge_port_changeupper()

On Wed, 2021-08-18 at 19:47 +0300, Vlad Buslov wrote:
> On Wed 18 Aug 2021 at 18:52, Tim Gardner <[email protected]>
> wrote:
> > 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]>
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]

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

> > Signed-off-by: Tim Gardner <[email protected]>
> > ---
>
> 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.

>
> Reviewed-by: Vlad Buslov <[email protected]>
>
> [...]
>
>