]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: socionext: Fix two sleep-in-atomic-context bugs in ave_rxfifo_reset()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Sat, 15 Sep 2018 04:02:46 +0000 (12:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Sep 2018 02:02:44 +0000 (19:02 -0700)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/socionext/sni_ave.c

index 61e6abb966ac79d0f8a287d7a74f141215d5c11d..2a156dcd45341214f74d0eb1c67490526f1d518f 100644 (file)
@@ -895,11 +895,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);