]> git.itanic.dy.fi Git - linux-stable/commit
net/mlx4_core: Fix use of ENOSPC around mlx4_counter_alloc()
authorTariq Toukan <tariqt@mellanox.com>
Mon, 4 May 2020 08:36:02 +0000 (11:36 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2020 06:15:25 +0000 (08:15 +0200)
commit4a0593e4fe3249d9f16d8419ca48c8b3a3b84cb3
tree759261601c991ff80378ec8b9b1bc6fd35074b5e
parentdc9d8659996df35ff927a3b25f2d8c3e6a5a83e2
net/mlx4_core: Fix use of ENOSPC around mlx4_counter_alloc()

[ Upstream commit 40e473071dbad04316ddc3613c3a3d1c75458299 ]

When ENOSPC is set the idx is still valid and gets set to the global
MLX4_SINK_COUNTER_INDEX.  However gcc's static analysis cannot tell that
ENOSPC is impossible from mlx4_cmd_imm() and gives this warning:

drivers/net/ethernet/mellanox/mlx4/main.c:2552:28: warning: 'idx' may be
used uninitialized in this function [-Wmaybe-uninitialized]
 2552 |    priv->def_counter[port] = idx;

Also, when ENOSPC is returned mlx4_allocate_default_counters should not
fail.

Fixes: 6de5f7f6a1fa ("net/mlx4_core: Allocate default counter per port")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlx4/main.c