[PATCH net v2 1/2] net: plip: quiesce private work before releasing resources

From: Hongyan Xu

Date: Sun Nov 15 2026 - 08:42:58 EST


PLIP can still run immediate or deferred work while close releases the
parport and pending skbs. Initialize both work items disabled and
disable and drain them before resource release.

Initialize state and enable the work before parport_claim(), since
claiming the port can already expose the interrupt handler. Restore the
disabled state on claim failure. This avoids dropping a trigger on
disabled work and then leaving the connection in receive state forever.

The separate second patch balances the controller IRQ across close and
an interrupted transfer; keep that repair separate from work quiescing.

Found by the author's in-house static analysis tool.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/all/20260928134136.1213-1-getshell@xxxxxxxxxx/
Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
Signed-off-by: Zehao Gao <gaozehao@xxxxxxxxx>
---

Discovery: found by the author's in-house static analysis tool.

drivers/net/plip/plip.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
index d81163b..dc3d258 100644
--- a/drivers/net/plip/plip.c
+++ b/drivers/net/plip/plip.c
@@ -308,6 +308,8 @@ plip_init_netdev(struct net_device *dev)
/* Initialize task queue structures */
INIT_WORK(&nl->immediate, plip_bh);
INIT_DELAYED_WORK(&nl->deferred, plip_kick_bh);
+ disable_work(&nl->immediate);
+ disable_delayed_work(&nl->deferred);

if (dev->irq == -1)
INIT_DELAYED_WORK(&nl->timer, plip_timer_bh);
@@ -1069,14 +1071,27 @@ plip_open(struct net_device *dev)
struct net_local *nl = netdev_priv(dev);
struct in_device *in_dev;

+ /* parport_claim() can make the interrupt handler reachable. */
+ nl->rcv_data.state = PLIP_PK_DONE;
+ nl->snd_data.state = PLIP_PK_DONE;
+ nl->rcv_data.skb = NULL;
+ nl->snd_data.skb = NULL;
+ nl->connection = PLIP_CN_NONE;
+ nl->is_deferred = 0;
+ nl->should_relinquish = 0;
+ enable_work(&nl->immediate);
+ enable_work(&nl->deferred.work);
+
/* Grab the port */
if (!nl->port_owner) {
- if (parport_claim(nl->pardev)) return -EAGAIN;
+ if (parport_claim(nl->pardev)) {
+ disable_work_sync(&nl->immediate);
+ disable_delayed_work_sync(&nl->deferred);
+ return -EAGAIN;
+ }
nl->port_owner = 1;
}

- nl->should_relinquish = 0;
-
/* Clear the data port. */
write_data (dev, 0x00);

@@ -1088,12 +1103,6 @@ plip_open(struct net_device *dev)
schedule_delayed_work(&nl->timer, 1);
}

- /* Initialize the state machine. */
- nl->rcv_data.state = nl->snd_data.state = PLIP_PK_DONE;
- nl->rcv_data.skb = nl->snd_data.skb = NULL;
- nl->connection = PLIP_CN_NONE;
- nl->is_deferred = 0;
-
/* Fill in the MAC-level header.
We used to abuse dev->broadcast to store the point-to-point
MAC address, but we no longer do it. Instead, we fetch the
@@ -1141,6 +1150,9 @@ plip_close(struct net_device *dev)
wait_for_completion(&nl->killed_timer_cmp);
}

+ disable_work_sync(&nl->immediate);
+ disable_delayed_work_sync(&nl->deferred);
+
#ifdef NOTDEF
outb(0x00, PAR_DATA(dev));
#endif
--
2.50.1.windows.1