lkml.org 
[lkml]   [2017]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] macb: Fix a possible sleep-in-atomic bug in macb_tx_error_task
Date
The driver may sleep under a spinlock.
The function call path is:
macb_tx_error_task (acquire the spinlock)
macb_halt_tx
usleep_range --> may sleep

To fix it, usleep_range is replaced with udelay.

This bug is found by my static analysis tool(DSAC) and checked by my code review.

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 72a67f7..b02c806 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -645,7 +645,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;
--
1.7.9.5
\
 
 \ /
  Last update: 2017-12-13 11:44    [W:0.062 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site