Message ID | 20200706110259.23947-1-alexandru.ardelean@analog.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] iio: dac: ad5592r: fix unbalanced mutex unlocks in ad5592r_read_raw() | expand |
On Mon, 2020-07-06 at 14:02 +0300, Alexandru Ardelean wrote: > [External] > > There are 2 exit paths where the lock isn't held, but try to unlock the > mutex when exiting. In these places we should just return from the > function. > > A neater approach would be to cleanup the ad5592r_read_raw(), but that > would make this patch more difficult to backport to stable versions. > I was a bit too hasty with this. Apologies. I'd like to add a tag here. Reported-by: Charles Stanhope <charles.stanhope@gmail.com> > Fixes 56ca9db862bf3: ("iio: dac: Add support for the AD5592R/AD5593R > ADCs/DACs") > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > --- > drivers/iio/dac/ad5592r-base.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r- > base.c > index 5c4e5ff70380..cc4875660a69 100644 > --- a/drivers/iio/dac/ad5592r-base.c > +++ b/drivers/iio/dac/ad5592r-base.c > @@ -413,7 +413,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, > s64 tmp = *val * (3767897513LL / 25LL); > *val = div_s64_rem(tmp, 1000000000LL, val2); > > - ret = IIO_VAL_INT_PLUS_MICRO; > + return IIO_VAL_INT_PLUS_MICRO; > } else { > int mult; > > @@ -444,7 +444,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, > ret = IIO_VAL_INT; > break; > default: > - ret = -EINVAL; > + return -EINVAL; > } > > unlock:
On Mon, 6 Jul 2020 16:36:09 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > On Mon, 2020-07-06 at 14:02 +0300, Alexandru Ardelean wrote: > > [External] > > > > There are 2 exit paths where the lock isn't held, but try to unlock the > > mutex when exiting. In these places we should just return from the > > function. > > > > A neater approach would be to cleanup the ad5592r_read_raw(), but that > > would make this patch more difficult to backport to stable versions. > > > > I was a bit too hasty with this. > Apologies. > I'd like to add a tag here. > > Reported-by: Charles Stanhope <charles.stanhope@gmail.com> Applied to the fixes-togreg branch of iio.git. I'll have to wait for this to trickle through to the togreg branch though before I can do anything with the next two patches. As ever, if I've clearly lost them give me a poke! Jonathan > > > Fixes 56ca9db862bf3: ("iio: dac: Add support for the AD5592R/AD5593R > > ADCs/DACs") > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > > --- > > drivers/iio/dac/ad5592r-base.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r- > > base.c > > index 5c4e5ff70380..cc4875660a69 100644 > > --- a/drivers/iio/dac/ad5592r-base.c > > +++ b/drivers/iio/dac/ad5592r-base.c > > @@ -413,7 +413,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, > > s64 tmp = *val * (3767897513LL / 25LL); > > *val = div_s64_rem(tmp, 1000000000LL, val2); > > > > - ret = IIO_VAL_INT_PLUS_MICRO; > > + return IIO_VAL_INT_PLUS_MICRO; > > } else { > > int mult; > > > > @@ -444,7 +444,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, > > ret = IIO_VAL_INT; > > break; > > default: > > - ret = -EINVAL; > > + return -EINVAL; > > } > > > > unlock:
diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c index 5c4e5ff70380..cc4875660a69 100644 --- a/drivers/iio/dac/ad5592r-base.c +++ b/drivers/iio/dac/ad5592r-base.c @@ -413,7 +413,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, s64 tmp = *val * (3767897513LL / 25LL); *val = div_s64_rem(tmp, 1000000000LL, val2); - ret = IIO_VAL_INT_PLUS_MICRO; + return IIO_VAL_INT_PLUS_MICRO; } else { int mult; @@ -444,7 +444,7 @@ static int ad5592r_read_raw(struct iio_dev *iio_dev, ret = IIO_VAL_INT; break; default: - ret = -EINVAL; + return -EINVAL; } unlock:
There are 2 exit paths where the lock isn't held, but try to unlock the mutex when exiting. In these places we should just return from the function. A neater approach would be to cleanup the ad5592r_read_raw(), but that would make this patch more difficult to backport to stable versions. Fixes 56ca9db862bf3: ("iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs") Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> --- drivers/iio/dac/ad5592r-base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)