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