net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sat, 15 Sep 2018 04:02:46 +0000 (12:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:46:52 +0000 (18:46 +0100)
commit80ec7fcb04a04ce1dcad8c96220dd1f0f056b0da
treed7737715bd78398511acdd0cbf73f45b4ceb8f5c
parent176f6203a4f415d73b9c4092d889cc4435b2bbc3
net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset()

[ Upstream commit 0020f5c807ef67954d9210eea0ba17a6134cdf7d ]

The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] usleep_range
drivers/net/ethernet/socionext/sni_ave.c, 892:
usleep_range in ave_rxfifo_reset
drivers/net/ethernet/socionext/sni_ave.c, 932:
ave_rxfifo_reset in ave_irq_handler

[FUNC] usleep_range
drivers/net/ethernet/socionext/sni_ave.c, 888:
usleep_range in ave_rxfifo_reset
drivers/net/ethernet/socionext/sni_ave.c, 932:
ave_rxfifo_reset in ave_irq_handler

To fix these bugs, usleep_range() is replaced with udelay().

These bugs are found by my static analysis tool DSAC.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/socionext/sni_ave.c