Skip to contentSkip to conversation

iio:buffer: Free active scan mask in iio_disable_all_buffers()

PATCH In review Lars-Peter Clausen 2 participants 3 messages Oct 15, 2013 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio:buffer: Free active scan mask in iio_disable_all_buffers()

Usually the active scan mask is freed in __iio_update_buffers() when the buffer is disabled. But when the device is still sampling when it is removed we'll end up disabling the buffers in iio_disable_all_buffers(). So we also need to free the active scan mask here, otherwise it will be leaked.

---
 drivers/iio/industrialio-buffer.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/industrialio-buffer.c +3 -0
index 796376a..1c72080 100644
@@ -490,6 +490,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
 	indio_dev->currentmode = INDIO_DIRECT_MODE;
 	if (indio_dev->setup_ops->postdisable)
 		indio_dev->setup_ops->postdisable(indio_dev);
+
+	if (indio_dev->available_scan_masks == NULL)
+		kfree(indio_dev->active_scan_mask);
 }
 
 static int __iio_update_buffers(struct iio_dev *indio_dev,
Signature · 1 line
1.8.0
maintainer
#1 lore raw
Quoted 6 lines · Lars-Peter Clausen

Usually the active scan mask is freed in __iio_update_buffers() when the buffer is disabled. But when the device is still sampling when it is removed we'll end up disabling the buffers in iio_disable_all_buffers(). So we also need to free the active scan mask here, otherwise it will be leaked.

Good spot. Applied to the togreg branch of iio.git

Thanks,

Jonathan

Quoted 19 lines
---
 drivers/iio/industrialio-buffer.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/industrialio-buffer.c +3 -0
index 796376a..1c72080 100644
@@ -490,6 +490,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
 	indio_dev->currentmode = INDIO_DIRECT_MODE;
 	if (indio_dev->setup_ops->postdisable)
 		indio_dev->setup_ops->postdisable(indio_dev);
+
+	if (indio_dev->available_scan_masks == NULL)
+		kfree(indio_dev->active_scan_mask);
 }
 
 static int __iio_update_buffers(struct iio_dev *indio_dev,
maintainer
#2 lore raw
Quoted 8 lines · Jonathan Cameron
Quoted 6 lines · Lars-Peter Clausen

Usually the active scan mask is freed in __iio_update_buffers() when the buffer is disabled. But when the device is still sampling when it is removed we'll end up disabling the buffers in iio_disable_all_buffers(). So we also need to free the active scan mask here, otherwise it will be leaked.

Good spot. Applied to the togreg branch of iio.git

Actually given how small this is and obviously correct + the fact it is a fix for a fix that did go via fixes-togreg I'll apply it via the fixes-togreg branch. Have to send a pull request in the next day or so for that branch anyway.

Thanks,

Jonathan

Quoted 28 lines

Thanks,

Jonathan

Quoted 10 lines
---
 drivers/iio/industrialio-buffer.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iio/industrialio-buffer.c +0 -0
index 796376a..1c72080 100644

drivers/iio/industrialio-buffer.c void iio_disable_all_buffers(struct iio_dev *indio_dev) · line 498

Quoted 9 lines
drivers/iio/industrialio-buffer.c +3 -0
@@ -490,6 +490,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
 	indio_dev->currentmode = INDIO_DIRECT_MODE;
 	if (indio_dev->setup_ops->postdisable)
 		indio_dev->setup_ops->postdisable(indio_dev);
+
+	if (indio_dev->available_scan_masks == NULL)
+		kfree(indio_dev->active_scan_mask);
 }
 
 static int __iio_update_buffers(struct iio_dev *indio_dev,

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html