Skip to contentSkip to conversation

net: phy: spi_ks8895: Don't leak references to SPI devices

PATCH Applied Mark Brown 2 participants 2 messages Apr 20, 2016 – Apr 21, 2016

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 net: phy: spi_ks8895: Don't leak references to SPI devices

The ks8895 driver is using spi_dev_get() apparently just to take a copy of the SPI device used to instantiate it but never calls spi_dev_put() to free it. Since the device is guaranteed to exist between probe() and remove() there should be no need for the driver to take an extra reference to it so fix the leak by just using a straight assignment.

---
 drivers/net/phy/spi_ks8995.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/spi_ks8995.c +1 -1
index b5d50d458728..93ffedfa2994 100644
@@ -441,7 +441,7 @@ static int ks8995_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	mutex_init(&ks->lock);
-	ks->spi = spi_dev_get(spi);
+	ks->spi = spi;
 	ks->chip = &ks8995_chip[variant];
 
 	if (ks->spi->dev.of_node) {
Signature · 1 line
2.8.0.rc3
maintainer Applied
#1 lore raw

From: Mark Brown <[email protected]>
Date: Wed, 20 Apr 2016 12:54:05 +0100

Quoted 7 lines

The ks8895 driver is using spi_dev_get() apparently just to take a copy of the SPI device used to instantiate it but never calls spi_dev_put() to free it. Since the device is guaranteed to exist between probe() and remove() there should be no need for the driver to take an extra reference to it so fix the leak by just using a straight assignment.

Applied.