From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org, frank@zago.net
Subject: Re: [PATCH] iio:accel:kxsd9 fix missing mutex unlock
Date: Wed, 13 Nov 2013 22:54:34 +0000 [thread overview]
Message-ID: <5284032A.9030509@kernel.org> (raw)
In-Reply-To: <5283E396.9020301@metafoo.de>
On 11/13/13 20:39, Lars-Peter Clausen wrote:
> On 11/13/2013 09:27 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>
>> ---
>> I have reworked this from a patch sent to me by Frank and put it
>> into the correct format.
>>
>> Frank, do you mind me adding your sign off on this. It's shorter
>> than your patch, but the effect is the same. This approach of unlocking
>> before checking a return value is a common kernel idiom.
>>
>> Jonathan
>>
>> drivers/iio/accel/kxsd9.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
>> index d72118d1189c..12df91986dd2 100644
>> --- a/drivers/iio/accel/kxsd9.c
>> +++ b/drivers/iio/accel/kxsd9.c
>> @@ -112,6 +112,7 @@ 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));
>> + mutex_unlock(&st->buf_lock);
>> if (ret)
>> return ret;
>> return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
>
> I think you'll need to hold the lock until you've actually read the data from the buffer.
Good point, I wasn't thinking through what it was actually for. Frank was in fact much more correct. I'll post his
version in a sec.
>
> - Lars
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2013-11-13 21:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 20:27 [PATCH] iio:accel:kxsd9 fix missing mutex unlock Jonathan Cameron
2013-11-13 20:39 ` Lars-Peter Clausen
2013-11-13 22:54 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5284032A.9030509@kernel.org \
--to=jic23@kernel.org \
--cc=frank@zago.net \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).