batman-adv: Request iflink once in batadv-on-batadv check
authorSven Eckelmann <sven@narfation.org>
Sun, 27 Feb 2022 23:01:24 +0000 (00:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Mar 2022 18:09:33 +0000 (19:09 +0100)
commitdcf10d78ff2c38dc5097cb59ae44367db17ed0c0
tree44b0eab8519b7d72ed3015f0f520e73f094e6b56
parent81f817f3e559d3e4e56110f6132f8322a97fbc8c
batman-adv: Request iflink once in batadv-on-batadv check

commit 690bb6fb64f5dc7437317153902573ecad67593d upstream.

There is no need to call dev_get_iflink multiple times for the same
net_device in batadv_is_on_batman_iface. And since some of the
.ndo_get_iflink callbacks are dynamic (for example via RCUs like in
vxcan_get_iflink), it could easily happen that the returned values are not
stable. The pre-checks before __dev_get_by_index are then of course bogus.

Fixes: b7eddd0b3950 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/batman-adv/hard-interface.c