On 10/23/13 18:44, Lars-Peter Clausen wrote: > The code is actually fine as it is. The iio_kfifo_free() function drops a reference, but does not free the buffer's memory if somebody else is still holding a reference. > > - Lars I'm guessing this came from a crash though.... Sebastian, what motivated the patch? > > Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> wrote: > >> Since commit 9e69c9 ("iio: Add reference counting for buffers") the iio >> core frees the buffer. So if the driver does it as well then bad things >> will happen. >> >> Cc: Lars-Peter Clausen <lars@xxxxxxxxxx> >> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> >> --- >> >> By no means I am the expert here but the other users of iio_kfifo_free() like >> >> drivers/iio/industrialio-triggered-buffer.c: iio_kfifo_free(indio_dev->buffer); >> drivers/iio/industrialio-triggered-buffer.c: iio_kfifo_free(indio_dev->buffer); >> >> are probably wrong, too. Not to mention staging. So *I* think iio_kfifo_free() >> should vanish from the tree. >> >> drivers/iio/adc/ti_am335x_adc.c | 3 --- >> 1 file changed, 3 deletions(-) >> >> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c >> index f974dea..3d70f09 100644 >> --- a/drivers/iio/adc/ti_am335x_adc.c >> +++ b/drivers/iio/adc/ti_am335x_adc.c >> @@ -254,8 +254,6 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev, >> >> error_free_irq: >> free_irq(irq, indio_dev); >> -error_kfifo_free: >> - iio_kfifo_free(indio_dev->buffer); >> return ret; >> } >> >> @@ -264,7 +262,6 @@ static void tiadc_iio_buffered_hardware_remove(struct iio_dev *indio_dev) >> struct tiadc_device *adc_dev = iio_priv(indio_dev); >> >> free_irq(adc_dev->mfd_tscadc->irq, indio_dev); >> - iio_kfifo_free(indio_dev->buffer); >> iio_buffer_unregister(indio_dev); >> } >> >> -- >> 1.8.4.rc3 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in >> the body of a message to majordomo@xxxxxxxxxxxxxxx >> More majordomo info at http://vger.kernel.org/majordomo-info.html > N�����r��y���b�X��ǧv�^�){.n�+����{��*"��^n�r���z���h����&���G���h�(�階�ݢj"���m�����z�ޖ���f���h���~�mml== > -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html