Thread (5 messages) flat view 5 messages, 3 authors, 1h ago
HOTtoday

[PATCH] net: dsa: vitesse-vsc73xx: Fix SPI device reference leak in vsc73xx_spi_probe()

From: Wentao Liang <hidden>
Date: 2026-09-17 10:49:28
Also in: lkml, stable
Subsystem: networking drivers, networking [dsa], the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn, Vladimir Oltean, Linus Torvalds

spi_dev_get() takes a reference on the SPI device, but neither the
probe error paths nor vsc73xx_spi_remove() ever release it, so the
spi_device can never be freed after the driver has been unbound.

Release the reference on both probe error paths and in remove().

Fixes: 95711cd5f0b4 ("net: dsa: vsc73xx: Split vsc73xx driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <redacted>
---
 drivers/net/dsa/vitesse-vsc73xx-spi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-spi.c b/drivers/net/dsa/vitesse-vsc73xx-spi.c
index 85b9a0f51dd8..7b784320c41e 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-spi.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-spi.c
@@ -153,10 +153,15 @@ static int vsc73xx_spi_probe(struct spi_device *spi)
 	ret = spi_setup(spi);
 	if (ret < 0) {
 		dev_err(dev, "spi setup failed.\n");
+		spi_dev_put(vsc_spi->spi);
 		return ret;
 	}
 
-	return vsc73xx_probe(&vsc_spi->vsc);
+	ret = vsc73xx_probe(&vsc_spi->vsc);
+	if (ret)
+		spi_dev_put(vsc_spi->spi);
+
+	return ret;
 }
 
 static void vsc73xx_spi_remove(struct spi_device *spi)
@@ -167,6 +172,8 @@ static void vsc73xx_spi_remove(struct spi_device *spi)
 		return;
 
 	vsc73xx_remove(&vsc_spi->vsc);
+
+	spi_dev_put(vsc_spi->spi);
 }
 
 static void vsc73xx_spi_shutdown(struct spi_device *spi)
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help