RDMA/mlx4: Avoid false error about access to uninitialized gids array

[ Upstream commit 1f53d88cbb0dcc7df235bf6611ae632b254fccd8 ]

Smatch generates the following false error report:
drivers/infiniband/hw/mlx4/main.c:393 mlx4_ib_del_gid() error: uninitialized symbol 'gids'.

Traditionally, we are not changing kernel code and asking people to fix
the tools. However in this case, the fix can be done by simply rearranging
the code to be more clear.

Fixes: e26be1bfef ("IB/mlx4: Implement ib_device callbacks")
Link: https://patch.msgid.link/6a3a1577463da16962463fcf62883a87506e9b62.1733233426.git.leonro@nvidia.com
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Leon Romanovsky
2024-12-03 15:44:25 +02:00
committed by Greg Kroah-Hartman
parent f192654731
commit 2d4c46ad83

View File

@@ -384,10 +384,10 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
} }
spin_unlock_bh(&iboe->lock); spin_unlock_bh(&iboe->lock);
if (!ret && hw_update) { if (gids)
ret = mlx4_ib_update_gids(gids, ibdev, attr->port_num); ret = mlx4_ib_update_gids(gids, ibdev, attr->port_num);
kfree(gids);
} kfree(gids);
return ret; return ret;
} }