1 From 5833532b49820aa221248f296c207cc50d20ca2d Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Fri, 23 Dec 2016 19:36:31 -0800
4 Subject: [PATCH net] net: korina: Fix NAPI versus resources freeing
6 Commit beb0babfb77e ("korina: disable napi on close and restart")
7 introduced calls to napi_disable() that were missing before,
8 unfortunately this leaves a small window during which NAPI has a chance
9 to run, yet we just freed resources since korina_free_ring() has been
12 Fix this by disabling NAPI first then freeing resource, and make sure
13 that we also cancel the restart taks before doing the resource freeing.
15 Fixes: beb0babfb77e ("korina: disable napi on close and restart")
16 Reported-by: Alexandros C. Couloumbis <alex@ozo.com>
17 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
19 drivers/net/ethernet/korina.c | 8 ++++----
20 1 file changed, 4 insertions(+), 4 deletions(-)
22 --- a/drivers/net/ethernet/korina.c
23 +++ b/drivers/net/ethernet/korina.c
24 @@ -900,10 +900,10 @@ static void korina_restart_task(struct w
25 DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR,
26 &lp->rx_dma_regs->dmasm);
28 - korina_free_ring(dev);
30 napi_disable(&lp->napi);
32 + korina_free_ring(dev);
34 if (korina_init(dev) < 0) {
35 printk(KERN_ERR "%s: cannot restart device\n", dev->name);
37 @@ -1064,12 +1064,12 @@ static int korina_close(struct net_devic
38 tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR;
39 writel(tmp, &lp->rx_dma_regs->dmasm);
41 - korina_free_ring(dev);
43 napi_disable(&lp->napi);
45 cancel_work_sync(&lp->restart_task);
47 + korina_free_ring(dev);
49 free_irq(lp->rx_irq, dev);
50 free_irq(lp->tx_irq, dev);
51 free_irq(lp->ovr_irq, dev);