Skip to contentSkip to conversation

staging:iio:ad2s1210 fix a leak when device removed

PATCH NAK Jimmy Li 2 participants 3 messages Apr 29, 2014

Subsystems (4)
lore
Share & tools
lore

Jimmy Li

author
#0 lore raw

PATCH 1/1 staging:iio:ad2s1210 fix a leak when device removed

---
 drivers/staging/iio/resolver/ad2s1210.c |    1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/resolver/ad2s1210.c +1 -0
index 7fbaba4..3d6e123 100644
@@ -716,6 +716,7 @@ static int ad2s1210_remove(struct spi_device *spi)
 
 	iio_device_unregister(indio_dev);
 	ad2s1210_free_gpios(iio_priv(indio_dev));
+	devm_iio_device_free(&spi->dev, indio_dev);
 
 	return 0;
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 11 lines · Jimmy Li
---
 drivers/staging/iio/resolver/ad2s1210.c |    1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/resolver/ad2s1210.c +0 -0
index 7fbaba4..3d6e123 100644

drivers/staging/iio/resolver/ad2s1210.c static int ad2s1210_remove(struct spi_device *spi) · line 719

Quoted 4 lines
drivers/staging/iio/resolver/ad2s1210.c +1 -0
@@ -716,6 +716,7 @@ static int ad2s1210_remove(struct spi_device *spi)
 
 	iio_device_unregister(indio_dev);
 	ad2s1210_free_gpios(iio_priv(indio_dev));
+	devm_iio_device_free(&spi->dev, indio_dev);

NAK.

In ad2s1210_probe(),devm_iio_device_alloc() was already used. So, when ad2s1210_remove() is called, iio_device_free() will be called automatically. So, the leak never happens.

If you want to know about devm_* functions, please refer to the following.

Documentation/driver-model/devres.txt

Best regards,
Jingoo Han

Quoted 5 lines
drivers/staging/iio/resolver/ad2s1210.c +0 -1
 	return 0;
 }
--

1.7.9.5

author
#2 lore raw
Quoted 19 lines · Jingoo Han
Quoted 11 lines · Jimmy Li
---
 drivers/staging/iio/resolver/ad2s1210.c |    1 +
 1 file changed, 1 insertion(+)
drivers/staging/iio/resolver/ad2s1210.c +0 -0
index 7fbaba4..3d6e123 100644

drivers/staging/iio/resolver/ad2s1210.c static int ad2s1210_remove(struct spi_device *spi) · line 719

Quoted 4 lines
drivers/staging/iio/resolver/ad2s1210.c +1 -0
@@ -716,6 +716,7 @@ static int ad2s1210_remove(struct spi_device *spi)
 
 	iio_device_unregister(indio_dev);
 	ad2s1210_free_gpios(iio_priv(indio_dev));
+	devm_iio_device_free(&spi->dev, indio_dev);

NAK.

Quoted 8 lines

In ad2s1210_probe(),devm_iio_device_alloc() was already used. So, when ad2s1210_remove() is called, iio_device_free() will be called automatically. So, the leak never happens.

If you want to know about devm_* functions, please refer to the following.

Documentation/driver-model/devres.txt

Thank you for your reply,

I understand it now, just ignore this patch.

Quoted 9 lines

Best regards,
Jingoo Han

Quoted 5 lines
drivers/staging/iio/resolver/ad2s1210.c +0 -1
 	return 0;
 }
--

1.7.9.5