]> git.itanic.dy.fi Git - linux-stable/commit
nfp: flower: Fix a potential leak in nfp_tunnel_add_shared_mac()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 18 Feb 2022 13:15:35 +0000 (14:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2022 10:42:50 +0000 (11:42 +0100)
commitaf4bc921d39dffdb83076e0a7eed1321242b7d87
tree3f28f042c7f0423c188bfbac7cb5fe2faaa6d64a
parent58a6d5f24f49ab87f56b0045bb7abc3b701fa5c8
nfp: flower: Fix a potential leak in nfp_tunnel_add_shared_mac()

commit 3a14d0888eb4b0045884126acc69abfb7b87814d upstream.

ida_simple_get() returns an id between min (0) and max (NFP_MAX_MAC_INDEX)
inclusive.
So NFP_MAX_MAC_INDEX (0xff) is a valid id.

In order for the error handling path to work correctly, the 'invalid'
value for 'ida_idx' should not be in the 0..NFP_MAX_MAC_INDEX range,
inclusive.

So set it to -1.

Fixes: 20cce8865098 ("nfp: flower: enable MAC address sharing for offloadable devs")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20220218131535.100258-1-simon.horman@corigine.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c