diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2018-09-01 08:11:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-09-02 19:05:25 -0400 |
commit | 16fe10cf92783ed9ceb182d6ea2b8adf5e8ec1b8 (patch) | |
tree | dc652a85653af60c212ca20262c6d01e092a946d | |
parent | a80afe89d81af6b64bf2d9b3afef70dcf75df12b (diff) |
net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
The kernel module may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.16 are:
[FUNC] usleep_range
drivers/net/ethernet/cadence/macb_main.c, 648:
usleep_range in macb_halt_tx
drivers/net/ethernet/cadence/macb_main.c, 730:
macb_halt_tx in macb_tx_error_task
drivers/net/ethernet/cadence/macb_main.c, 721:
_raw_spin_lock_irqsave in macb_tx_error_task
To fix this bug, usleep_range() is replaced with udelay().
This bug is 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>
-rw-r--r-- | drivers/net/ethernet/cadence/macb_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index c6707ea2d751..16e4ef7d7185 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c | |||
@@ -649,7 +649,7 @@ static int macb_halt_tx(struct macb *bp) | |||
649 | if (!(status & MACB_BIT(TGO))) | 649 | if (!(status & MACB_BIT(TGO))) |
650 | return 0; | 650 | return 0; |
651 | 651 | ||
652 | usleep_range(10, 250); | 652 | udelay(250); |
653 | } while (time_before(halt_time, timeout)); | 653 | } while (time_before(halt_time, timeout)); |
654 | 654 | ||
655 | return -ETIMEDOUT; | 655 | return -ETIMEDOUT; |