kernel: bump to 4.4.40
[openwrt/staging/yousong.git] / target / linux / rb532 / patches-4.4 / 100-korina_fix_napi_disable.patch
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
5
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
10 called:
11
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.
14
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>
18 ---
19 drivers/net/ethernet/korina.c | 8 ++++----
20 1 file changed, 4 insertions(+), 4 deletions(-)
21
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);
27
28 - korina_free_ring(dev);
29 -
30 napi_disable(&lp->napi);
31
32 + korina_free_ring(dev);
33 +
34 if (korina_init(dev) < 0) {
35 printk(KERN_ERR "%s: cannot restart device\n", dev->name);
36 return;
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);
40
41 - korina_free_ring(dev);
42 -
43 napi_disable(&lp->napi);
44
45 cancel_work_sync(&lp->restart_task);
46
47 + korina_free_ring(dev);
48 +
49 free_irq(lp->rx_irq, dev);
50 free_irq(lp->tx_irq, dev);
51 free_irq(lp->ovr_irq, dev);