diff options
author | Jia-Ju Bai <baijiaju1990@gmail.com> | 2018-09-01 20:11:05 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-10 08:52:11 +0200 |
commit | ca8aa9f49b569ac6647dd5dad3ba4072e2e70c1e (patch) | |
tree | b7ceabc0ec95a58458854f3be41dacb5a067356c /drivers/net/ethernet | |
parent | 293c9b05879be53b17f80985123d93537264a875 (diff) | |
download | linux-stable-ca8aa9f49b569ac6647dd5dad3ba4072e2e70c1e.tar.gz linux-stable-ca8aa9f49b569ac6647dd5dad3ba4072e2e70c1e.tar.bz2 linux-stable-ca8aa9f49b569ac6647dd5dad3ba4072e2e70c1e.zip |
net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
[ Upstream commit 16fe10cf92783ed9ceb182d6ea2b8adf5e8ec1b8 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/cadence/macb.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 8d54e7b41bbf..8c698d464716 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -523,7 +523,7 @@ static int macb_halt_tx(struct macb *bp) if (!(status & MACB_BIT(TGO))) return 0; - usleep_range(10, 250); + udelay(250); } while (time_before(halt_time, timeout)); return -ETIMEDOUT; |