Skip to content

Commit

Permalink
staging:iio:lis3l02dq: Do not return a error in remove function
Browse files Browse the repository at this point in the history
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Sep 22, 2012
1 parent e854bcc commit e71a837
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/staging/iio/accel/lis3l02dq_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,19 +782,13 @@ static int lis3l02dq_stop_device(struct iio_dev *indio_dev)
/* fixme, confirm ordering in this function */
static int __devexit lis3l02dq_remove(struct spi_device *spi)
{
int ret;
struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct lis3l02dq_state *st = iio_priv(indio_dev);

iio_device_unregister(indio_dev);

ret = lis3l02dq_disable_all_events(indio_dev);
if (ret)
goto err_ret;

ret = lis3l02dq_stop_device(indio_dev);
if (ret)
goto err_ret;
lis3l02dq_disable_all_events(indio_dev);
lis3l02dq_stop_device(indio_dev);

if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
free_irq(st->us->irq, indio_dev);
Expand All @@ -804,8 +798,8 @@ static int __devexit lis3l02dq_remove(struct spi_device *spi)
lis3l02dq_unconfigure_buffer(indio_dev);

iio_device_free(indio_dev);
err_ret:
return ret;

return 0;
}

static struct spi_driver lis3l02dq_driver = {
Expand Down

0 comments on commit e71a837

Please sign in to comment.