Skip to contentSkip to conversation

net: korina: Fix NAPI versus resources freeing

PATCH Applied Florian Fainelli 2 participants 2 messages Dec 24, 2016 – Dec 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: korina: Fix NAPI versus resources freeing

Commit beb0babfb77e ("korina: disable napi on close and restart") introduced calls to napi_disable() that were missing before, unfortunately this leaves a small window during which NAPI has a chance to run, yet we just freed resources since korina_free_ring() has been called:

Fix this by disabling NAPI first then freeing resource, and make sure that we also cancel the restart taks before doing the resource freeing.

Fixes beb0babfb77e ("korina: disable napi on close and restart")
---
 drivers/net/ethernet/korina.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/korina.c +4 -4
index cbeea915f026..8037426ec50f 100644
@@ -900,10 +900,10 @@ static void korina_restart_task(struct work_struct *work)
 				DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR,
 				&lp->rx_dma_regs->dmasm);
 
-	korina_free_ring(dev);
-
 	napi_disable(&lp->napi);
 
+	korina_free_ring(dev);
+
 	if (korina_init(dev) < 0) {
 		printk(KERN_ERR "%s: cannot restart device\n", dev->name);
 		return;
@@ -1064,12 +1064,12 @@ static int korina_close(struct net_device *dev)
 	tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR;
 	writel(tmp, &lp->rx_dma_regs->dmasm);
 
-	korina_free_ring(dev);
-
 	napi_disable(&lp->napi);
 
 	cancel_work_sync(&lp->restart_task);
 
+	korina_free_ring(dev);
+
 	free_irq(lp->rx_irq, dev);
 	free_irq(lp->tx_irq, dev);
 	free_irq(lp->ovr_irq, dev);
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw

From: Florian Fainelli <[email protected]>
Date: Fri, 23 Dec 2016 19:56:56 -0800

Quoted 6 lines

Commit beb0babfb77e ("korina: disable napi on close and restart") introduced calls to napi_disable() that were missing before, unfortunately this leaves a small window during which NAPI has a chance to run, yet we just freed resources since korina_free_ring() has been called:

Quoted 6 lines

Fix this by disabling NAPI first then freeing resource, and make sure that we also cancel the restart taks before doing the resource freeing.

Fixes beb0babfb77e ("korina: disable napi on close and restart")

Applied, thanks.