* [PATCH] net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset()
@ 2018-09-15 4:02 Jia-Ju Bai
2018-09-18 2:03 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-09-15 4:02 UTC (permalink / raw)
To: davem, hayashi.kunihiko, yamada.masahiro, robh, andrew
Cc: netdev, linux-kernel, Jia-Ju Bai
The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.17 are:
[FUNC] usleep_range
drivers/net/ethernet/socionext/sni_ave.c, 892:
usleep_range in ave_rxfifo_reset
drivers/net/ethernet/socionext/sni_ave.c, 932:
ave_rxfifo_reset in ave_irq_handler
[FUNC] usleep_range
drivers/net/ethernet/socionext/sni_ave.c, 888:
usleep_range in ave_rxfifo_reset
drivers/net/ethernet/socionext/sni_ave.c, 932:
ave_rxfifo_reset in ave_irq_handler
To fix these bugs, usleep_range() is replaced with udelay().
These bugs are found by my static analysis tool DSAC.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/net/ethernet/socionext/sni_ave.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c
index f7ecceeb1e28..3c784a29ce0d 100644
--- a/drivers/net/ethernet/socionext/sni_ave.c
+++ b/drivers/net/ethernet/socionext/sni_ave.c
@@ -904,11 +904,11 @@ static void ave_rxfifo_reset(struct net_device *ndev)
/* assert reset */
writel(AVE_GRR_RXFFR, priv->base + AVE_GRR);
- usleep_range(40, 50);
+ udelay(50);
/* negate reset */
writel(0, priv->base + AVE_GRR);
- usleep_range(10, 20);
+ udelay(20);
/* negate interrupt status */
writel(AVE_GI_RXOVF, priv->base + AVE_GISR);
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset()
2018-09-15 4:02 [PATCH] net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset() Jia-Ju Bai
@ 2018-09-18 2:03 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-09-18 2:03 UTC (permalink / raw)
To: baijiaju1990
Cc: hayashi.kunihiko, yamada.masahiro, robh, andrew, netdev,
linux-kernel
From: Jia-Ju Bai <baijiaju1990@gmail.com>
Date: Sat, 15 Sep 2018 12:02:46 +0800
> The driver may sleep with holding a spinlock.
> The function call paths (from bottom to top) in Linux-4.17 are:
>
> [FUNC] usleep_range
> drivers/net/ethernet/socionext/sni_ave.c, 892:
> usleep_range in ave_rxfifo_reset
> drivers/net/ethernet/socionext/sni_ave.c, 932:
> ave_rxfifo_reset in ave_irq_handler
>
> [FUNC] usleep_range
> drivers/net/ethernet/socionext/sni_ave.c, 888:
> usleep_range in ave_rxfifo_reset
> drivers/net/ethernet/socionext/sni_ave.c, 932:
> ave_rxfifo_reset in ave_irq_handler
>
> To fix these bugs, usleep_range() is replaced with udelay().
>
> These bugs are found by my static analysis tool DSAC.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Applied to net-next.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-18 2:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-15 4:02 [PATCH] net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset() Jia-Ju Bai
2018-09-18 2:03 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).