linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio:buffer: Free active scan mask in iio_disable_all_buffers()
@ 2013-10-15  8:38 Lars-Peter Clausen
  2013-10-15 18:23 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2013-10-15  8:38 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, 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.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/industrialio-buffer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 796376a..1c72080 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -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,
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio:buffer: Free active scan mask in iio_disable_all_buffers()
  2013-10-15  8:38 [PATCH] iio:buffer: Free active scan mask in iio_disable_all_buffers() Lars-Peter Clausen
@ 2013-10-15 18:23 ` Jonathan Cameron
  2013-10-15 18:27   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2013-10-15 18:23 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 10/15/13 09:38, Lars-Peter Clausen wrote:
> 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.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Good spot. Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/industrialio-buffer.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 796376a..1c72080 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -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,
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio:buffer: Free active scan mask in iio_disable_all_buffers()
  2013-10-15 18:23 ` Jonathan Cameron
@ 2013-10-15 18:27   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2013-10-15 18:27 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 10/15/13 19:23, Jonathan Cameron wrote:
> On 10/15/13 09:38, Lars-Peter Clausen wrote:
>> 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.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> 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
> 
> Thanks,
> 
> Jonathan
>> ---
>>  drivers/iio/industrialio-buffer.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
>> index 796376a..1c72080 100644
>> --- a/drivers/iio/industrialio-buffer.c
>> +++ b/drivers/iio/industrialio-buffer.c
>> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-15 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15  8:38 [PATCH] iio:buffer: Free active scan mask in iio_disable_all_buffers() Lars-Peter Clausen
2013-10-15 18:23 ` Jonathan Cameron
2013-10-15 18:27   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).