All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] iio:accel:kxsd9 fix missing mutex unlock
@ 2013-11-13 22:53 Jonathan Cameron
  2013-11-14  0:41 ` Frank Zago
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2013-11-13 22:53 UTC (permalink / raw)
  To: linux-iio; +Cc: frank, lars, Jonathan Cameron

From: Frank Zago <frank@zago.net>

This will leave a lock held after reading from the device, preventing
any further reads.

Signed-off-by: Frank Zago <frank@zago.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---

This is Frank's original patch.  As Lars-Peter pointed out, I really didn't
think my way through my shortened (and incorrect version).

Oops!

Frank, just to check, are you fine signing off on this?

 drivers/iio/accel/kxsd9.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index d72118d1189c..98ba761cbb9c 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
 	mutex_lock(&st->buf_lock);
 	st->tx[0] = KXSD9_READ(address);
 	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
-	if (ret)
-		return ret;
-	return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
+	if (!ret)
+		ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
+	mutex_unlock(&st->buf_lock);
+	return ret;
 }
 
 static IIO_CONST_ATTR(accel_scale_available,
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] iio:accel:kxsd9 fix missing mutex unlock
  2013-11-13 22:53 [PATCH V2] iio:accel:kxsd9 fix missing mutex unlock Jonathan Cameron
@ 2013-11-14  0:41 ` Frank Zago
  2013-11-17 15:23   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Zago @ 2013-11-14  0:41 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: lars

On 11/13/2013 04:53 PM, Jonathan Cameron wrote:
> From: Frank Zago <frank@zago.net>
> 
> This will leave a lock held after reading from the device, preventing
> any further reads.
> 
> Signed-off-by: Frank Zago <frank@zago.net>
> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
> ---
> 
> This is Frank's original patch.  As Lars-Peter pointed out, I really didn't
> think my way through my shortened (and incorrect version).
> 
> Oops!
> 
> Frank, just to check, are you fine signing off on this?

Yes. It's good.

Frank.

> 
>  drivers/iio/accel/kxsd9.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
> index d72118d1189c..98ba761cbb9c 100644
> --- a/drivers/iio/accel/kxsd9.c
> +++ b/drivers/iio/accel/kxsd9.c
> @@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
>  	mutex_lock(&st->buf_lock);
>  	st->tx[0] = KXSD9_READ(address);
>  	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
> -	if (ret)
> -		return ret;
> -	return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
> +	if (!ret)
> +		ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
> +	mutex_unlock(&st->buf_lock);
> +	return ret;
>  }
>  
>  static IIO_CONST_ATTR(accel_scale_available,
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] iio:accel:kxsd9 fix missing mutex unlock
  2013-11-14  0:41 ` Frank Zago
@ 2013-11-17 15:23   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2013-11-17 15:23 UTC (permalink / raw)
  To: Frank Zago, linux-iio; +Cc: lars

On 11/14/13 00:41, Frank Zago wrote:
> On 11/13/2013 04:53 PM, Jonathan Cameron wrote:
>> From: Frank Zago <frank@zago.net>
>>
>> This will leave a lock held after reading from the device, preventing
>> any further reads.
>>
>> Signed-off-by: Frank Zago <frank@zago.net>
>> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
>> ---
>>
>> This is Frank's original patch.  As Lars-Peter pointed out, I really didn't
>> think my way through my shortened (and incorrect version).
>>
>> Oops!
>>
>> Frank, just to check, are you fine signing off on this?
> 
> Yes. It's good.
> 
Applied to the fixes-togreg branch of iio.git
Also marked this as for stable.

Thanks,
> Frank.
> 
>>
>>  drivers/iio/accel/kxsd9.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
>> index d72118d1189c..98ba761cbb9c 100644
>> --- a/drivers/iio/accel/kxsd9.c
>> +++ b/drivers/iio/accel/kxsd9.c
>> @@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
>>  	mutex_lock(&st->buf_lock);
>>  	st->tx[0] = KXSD9_READ(address);
>>  	ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
>> -	if (ret)
>> -		return ret;
>> -	return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
>> +	if (!ret)
>> +		ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
>> +	mutex_unlock(&st->buf_lock);
>> +	return ret;
>>  }
>>  
>>  static IIO_CONST_ATTR(accel_scale_available,
>>
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-17 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 22:53 [PATCH V2] iio:accel:kxsd9 fix missing mutex unlock Jonathan Cameron
2013-11-14  0:41 ` Frank Zago
2013-11-17 15:23   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.