* [PATCH] net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
@ 2018-09-01 12:11 Jia-Ju Bai
2018-09-02 23:05 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-09-01 12:11 UTC (permalink / raw)
To: nicolas.ferre, davem; +Cc: netdev, linux-kernel, Jia-Ju Bai
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>
---
drivers/net/ethernet/cadence/macb_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index a6c911bb5ce2..3dcc31cd4261 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -641,7 +641,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;
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
2018-09-01 12:11 [PATCH] net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx() Jia-Ju Bai
@ 2018-09-02 23:05 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-09-02 23:05 UTC (permalink / raw)
To: baijiaju1990; +Cc: nicolas.ferre, netdev, linux-kernel
From: Jia-Ju Bai <baijiaju1990@gmail.com>
Date: Sat, 1 Sep 2018 20:11:05 +0800
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-02 23:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-01 12:11 [PATCH] net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx() Jia-Ju Bai
2018-09-02 23:05 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.