iio: core: fix missing mutex_unlock() in iio_device_claim_buffer_mode()
PATCH 1/1 iio: core: fix missing mutex_unlock() in iio_device_claim_buffer_mode()
In the success path of iio_device_claim_buffer_mode(), mutex_unlock() should be called before return.
--- drivers/iio/industrialio-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/industrialio-core.c +3 -1
@@ -2102,8 +2102,10 @@ int iio_device_claim_buffer_mode(struct iio_dev *indio_dev)mutex_lock (&iio_dev_opaque->mlock); -if (iio_buffer_enabled (indio_dev)) +if (iio_buffer_enabled (indio_dev)) { +mutex_unlock (&iio_dev_opaque->mlock);return 0 ; + }mutex_unlock (&iio_dev_opaque->mlock);return -EBUSY ;
Signature · 1 line
2.17.1
Quoted 3 lines · Peng Wu
In the success path of
iio_device_claim_buffer_mode(),mutex_unlock()should be called before return.
Please, understand how the code works.
NAK.
Nuno, perhaps we need to put a comment inside the function to explain this?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Peng Wu
In the success path of
iio_device_claim_buffer_mode(),mutex_unlock()
should be called before return.
Quoted 6 lines
Please, understand how the code works.
NAK.Nuno, perhaps we need to put a comment inside the function to explain this?
Hmm... I guess we can do that but, honestly, the docs in the function should be pretty straight. Maybe saying that it's supposed to work as iio_device_claim_direct_mode() would help (as that one is familiar)...
Alternatively, having sparse annotations could also make it more easy to understand the intent.
- Nuno Sá
Quoted 14 lines · Nuno Sá
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Peng Wu
In the success path of
iio_device_claim_buffer_mode(),mutex_unlock()
should be called before return.Quoted 6 lines
Please, understand how the code works.
NAK.Nuno, perhaps we need to put a comment inside the function to explain this?
Quoted 6 lines
Hmm... I guess we can do that but, honestly, the docs in the function should be pretty straight. Maybe saying that it's supposed to work as
iio_device_claim_direct_mode()would help (as that one is familiar)...Alternatively, having sparse annotations could also make it more easy to understand the intent.
Maybe simply
/* Yes, we leave it locked here */
before return 0; would suffice?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 28 lines · Andy Shevchenko
Quoted 23 lines · Nuno Sá
Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Peng Wu
In the success path of
iio_device_claim_buffer_mode(),mutex_unlock()
should be called before return.Quoted 7 lines
Please, understand how the code works.
NAK.Nuno, perhaps we need to put a comment inside the function to explain
this?Hmm... I guess we can do that but, honestly, the docs in the function
should be pretty straight. Maybe saying that it's supposed to work asiio_device_claim_direct_mode()would help (as that one is familiar)...Quoted 3 lines
Alternatively, having sparse annotations could also make it more easy
to understand the intent.
Quoted 5 lines
Maybe simply
/* Yes, we leave it locked here */
before return 0; would suffice?
Yes, I think so...
- Nuno Sá