iio:dac:ad5449: unlock on error path
Subsystems (3)
PATCH 1/1 iio:dac:ad5449: unlock on error path
There is an unlock missing on this error path.
---
Only needed in linux-next.
drivers/iio/dac/ad5449.c +4 -3
@@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ret =spi_sync (st->spi, &msg);if (ret <0 ) -return ret; + goto out_unlock; *val =be16_to_cpu (st->data[1 ]); -mutex_unlock (&indio_dev->mlock); -return 0 ; +out_unlock: +mutex_unlock (&indio_dev->mlock); +return ret; } static int ad5449_read_raw(struct iio_dev *indio_dev,
Quoted 3 lines · Dan Carpenter
There is an unlock missing on this error path.
Signed-off-by Dan Carpenter <[email protected]>
Thanks,
Quoted 28 lines
---
Only needed in linux-next.drivers/iio/dac/ad5449.c +4
-4@@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ret =spi_sync (st->spi, &msg);if (ret <0 ) -return ret; + goto out_unlock; *val =be16_to_cpu (st->data[1 ]); -mutex_unlock (&indio_dev->mlock); -return 0 ; +out_unlock: +mutex_unlock (&indio_dev->mlock); +return ret; } static int ad5449_read_raw(struct iio_dev *indio_dev, --To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Lars-Peter Clausen
Quoted 3 lines · Dan Carpenter
There is an unlock missing on this error path.
Signed-off-by Dan Carpenter <[email protected]>Thanks,
Thanks applied to togreg branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Quoted 35 lines
Quoted 26 lines
---
Only needed in linux-next.drivers/iio/dac/ad5449.c +4
-4@@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ret =spi_sync (st->spi, &msg);if (ret <0 ) -return ret; + goto out_unlock; *val =be16_to_cpu (st->data[1 ]); -mutex_unlock (&indio_dev->mlock); -return 0 ; +out_unlock: +mutex_unlock (&indio_dev->mlock); +return ret; } static int ad5449_read_raw(struct iio_dev *indio_dev, --Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Am 02.11.2012 12:06, schrieb Jonathan Cameron:
Quoted 30 lines · Lars-Peter Clausen
Quoted 8 lines · Dan Carpenter
Quoted 3 lines
There is an unlock missing on this error path.
Signed-off-by Dan Carpenter <[email protected]>Thanks,
Thanks applied to togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.gitQuoted 18 lines
Quoted 18 lines
---
Only needed in linux-next.drivers/iio/dac/ad5449.c +1
-2@@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr, ret =spi_sync (st->spi, &msg);if (ret <0 ) -return ret; + goto out_unlock; *val =be16_to_cpu (st->data[1 ]); -mutex_unlock (&indio_dev->mlock);
Quoted 8 lines
Quoted 8 lines
drivers/iio/dac/ad5449.c static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
Quoted 8 lines
drivers/iio/dac/ad5449.c +3
-2-return 0 ; +out_unlock: +mutex_unlock (&indio_dev->mlock); +return ret; } static int ad5449_read_raw(struct iio_dev *indio_dev, --
if i understand the code correct you can simply the flow by turning the check on its head.
ret = spi_sync(st->spi, &msg);
if (ret>=0)
*val = be16_to_cpu(st->data[1]);
mutex_unlock(&indio_dev->mlock);
return ret;
re,
wh
Quoted 8 lines · walter harms
if i understand the code correct you can simply the flow by turning the check on its head.
ret =
spi_sync(st->spi, &msg);
if (ret>=0)*val = be16_to_cpu(st->data[1]);
mutex_unlock(&indio_dev->mlock);
return ret;
It's better to always treat errors as the special case and success as the normal case. It makes the code more readable if every check is consistent.
regards,
dan carpenter