net: lapbether: Prevent racing when checking whether the netif is running
authorXie He <xie.he.0141@gmail.com>
Thu, 11 Mar 2021 07:23:09 +0000 (23:23 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Mar 2021 18:32:28 +0000 (11:32 -0700)
commit5acd0cfbfbb5a688da1bfb1a2152b0c855115a35
tree1c7ae4c7cd302f650a60bdbf577b8fe071310b02
parent3f9c066abcab5bc48ea6bb353d7fc42b94aee786
net: lapbether: Prevent racing when checking whether the netif is running

There are two "netif_running" checks in this driver. One is in
"lapbeth_xmit" and the other is in "lapbeth_rcv". They serve to make
sure that the LAPB APIs called in these functions are called before
"lapb_unregister" is called by the "ndo_stop" function.

However, these "netif_running" checks are unreliable, because it's
possible that immediately after "netif_running" returns true, "ndo_stop"
is called (which causes "lapb_unregister" to be called).

This patch adds locking to make sure "lapbeth_xmit" and "lapbeth_rcv" can
reliably check and ensure the netif is running while doing their work.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Acked-by: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wan/lapbether.c