Skip to content

Commit 4a5b453

Browse files
tititiou36jic23
authored andcommitted
iio: sca3000: Fix an error handling path in 'sca3000_probe()'
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 <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 4177381 commit 4a5b453

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/iio/accel/sca3000.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
12771277
{
12781278
struct iio_buffer *buffer;
12791279

1280-
buffer = iio_kfifo_allocate();
1280+
buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
12811281
if (!buffer)
12821282
return -ENOMEM;
12831283

@@ -1287,11 +1287,6 @@ static int sca3000_configure_ring(struct iio_dev *indio_dev)
12871287
return 0;
12881288
}
12891289

1290-
static void sca3000_unconfigure_ring(struct iio_dev *indio_dev)
1291-
{
1292-
iio_kfifo_free(indio_dev->buffer);
1293-
}
1294-
12951290
static inline
12961291
int __sca3000_hw_ring_state_set(struct iio_dev *indio_dev, bool state)
12971292
{
@@ -1546,8 +1541,6 @@ static int sca3000_remove(struct spi_device *spi)
15461541
if (spi->irq)
15471542
free_irq(spi->irq, indio_dev);
15481543

1549-
sca3000_unconfigure_ring(indio_dev);
1550-
15511544
return 0;
15521545
}
15531546

0 commit comments

Comments
 (0)