Skip to content

Commit 16fe10c

Browse files
XidianGeneraldavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a80afe8 commit 16fe10c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static int macb_halt_tx(struct macb *bp)
649649
if (!(status & MACB_BIT(TGO)))
650650
return 0;
651651

652-
usleep_range(10, 250);
652+
udelay(250);
653653
} while (time_before(halt_time, timeout));
654654

655655
return -ETIMEDOUT;

0 commit comments

Comments
 (0)