net: hdlc_ppp: Fix issues when mod_timer is called while timer is running
authorXie He <xie.he.0141@gmail.com>
Mon, 28 Dec 2020 02:53:39 +0000 (18:53 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jan 2021 19:18:13 +0000 (20:18 +0100)
commit8ca1d23e6ad31e6df425221eaf82605137a9d803
tree567a556ee8e343dc3f065b9445273e2d46284bf8
parent0d6eeee3b9d4e08a9698038998d2752f157207f3
net: hdlc_ppp: Fix issues when mod_timer is called while timer is running

[ Upstream commit 1fef73597fa545c35fddc953979013882fbd4e55 ]

ppp_cp_event is called directly or indirectly by ppp_rx with "ppp->lock"
held. It may call mod_timer to add a new timer. However, at the same time
ppp_timer may be already running and waiting for "ppp->lock". In this
case, there's no need for ppp_timer to continue running and it can just
exit.

If we let ppp_timer continue running, it may call add_timer. This causes
kernel panic because add_timer can't be called with a timer pending.
This patch fixes this problem.

Fixes: e022c2f07ae5 ("WAN: new synchronous PPP implementation for generic HDLC.")
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wan/hdlc_ppp.c