Skip to content

net: phy: fix a second attach of an attached PHY and the module put on detach

Aleksei Sviridkin lkml netdev 4 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest2 patches 1 replyApplied 2/2
  2. v54 patches 5 repliesSuperseded
  3. v44 patches 1 replySuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v34 patches2 repliesSuperseded

Changes in v6 from the cover letter

https://lore.kernel.org/netdev/[email protected]/
- Dropped patches 3 and 4 (the bind_lock and the unbind wait), as Andrew suggested: unbinding a PHY driver is a development tool and not worth that complexity.
- Dropped the Fixes tags, the series targets net-next.
- Patch 2: added Andrew's Reviewed-by.

Patches in v6 All 2 applied

#Subject and filesSizeRepliesApplied
1/2net: phy: refuse a second attach before touching the PHYdrivers/net/phy/phy_device.c+7 -61 replyApplied
2/2net: phy: put the driver module the attach tookdrivers/net/phy/phy_device.c include/linux/phy.h+10 -40 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchAndrew Lunn
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH net-next v6 0/2] net: phy: fix a second attach of an attached PHY and the module put on detach

Two phylib fixes found on a Keenetic KN-1012 (MT7981) while chasing a PHY driver unbind race. A second attach of an attached PHY tears down the first consumer, and a detach after a driver unbind leaks the module reference.

1: refuse a second attach before the driver module is taken or the
generic driver bound.
2: put the module the attach pinned, not whatever driver is bound at
detach.

Patch 1 goes first: with patch 2 alone, the second attach error path leaves the first consumer's module reference pinned.

Changes in v6 (since v5):
https://lore.kernel.org/netdev/[email protected]/
- Dropped patches 3 and 4 (the bind_lock and the unbind wait), as Andrew suggested: unbinding a PHY driver is a development tool and not worth that complexity.
- Dropped the Fixes tags, the series targets net-next.
- Patch 2: added Andrew's Reviewed-by.

Aleksei Sviridkin (2):
net: phy: refuse a second attach before touching the PHY
net: phy: put the driver module the attach took

 drivers/net/phy/phy_device.c | 25 +++++++++++++++----------
 include/linux/phy.h          |  2 ++
 2 files changed, 17 insertions(+), 10 deletions(-)
Signature · 1 line
2.53.0