]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: sca3000: Fix an error handling path in 'sca3000_probe()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 8 Apr 2018 19:44:01 +0000 (21:44 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 15 Apr 2018 19:15:55 +0000 (20:15 +0100)
Use 'devm_iio_kfifo_allocate()' instead of 'iio_kfifo_allocate()' in order
to simplify code and avoid a memory leak in an error path in
'sca3000_probe()'. A call to 'sca3000_unconfigure_ring()' was missing.

Sent via the next merge window as unimportant bug and there are
other patches dependent on it.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/sca3000.c

index f33dadf7b2621b51aefd2b026815f6c959905137..562f125235dbc5351b7323305db6652c14bf6a12 100644 (file)
@@ -1277,7 +1277,7 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
 {
        struct iio_buffer *buffer;
 
-       buffer = iio_kfifo_allocate();
+       buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
        if (!buffer)
                return -ENOMEM;
 
@@ -1287,11 +1287,6 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
        return 0;
 }
 
-static void sca3000_unconfigure_ring(struct iio_dev *indio_dev)
-{
-       iio_kfifo_free(indio_dev->buffer);
-}
-
 static inline
 int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
 {
@@ -1546,8 +1541,6 @@ static int sca3000_remove(struct spi_device *spi)
        if (spi->irq)
                free_irq(spi->irq, indio_dev);
 
-       sca3000_unconfigure_ring(indio_dev);
-
        return 0;
 }