staging: iio: Fix locking in __iio_push_event
Subsystems (3)
PATCH 1/1 staging: iio: Fix locking in __iio_push_event
Correctly unlock the mutex when leaving the function. This was discovered by the stanse tool at
http://decibel.fi.muni.cz/~xslaby/stanse/error.cgi?db=33-rc&id=138
--- drivers/staging/iio/industrialio-core.c | 49 +++++++++++++++++-------------- 1 files changed, 27 insertions(+), 22 deletions(-)
drivers/staging/iio/industrialio-core.c +26 -21
@@ -78,28 +78,33 @@ EXPORT_SYMBOL(__iio_change_event);/* Does anyone care? */ mutex_lock (&ev_int->event_list_lock); -if (test_bit (IIO_BUSY_BIT_POS , &ev_int->handler.flags)) { -if (ev_int->current_events == ev_int->max_events) -return 0 ; - ev =kmalloc (sizeof (*ev),GFP_KERNEL ); -if (ev ==NULL ) { - ret = -ENOMEM ; - goto error_ret; - } - ev->ev.id = ev_code; - ev->ev.timestamp = timestamp; - ev->shared_pointer = shared_pointer_p; -if (ev->shared_pointer) - shared_pointer_p->ev_p = ev; - -list_add_tail (&ev->list, &ev_int->det_events.list); - ev_int->current_events++; -mutex_unlock (&ev_int->event_list_lock); -wake_up_interruptible (&ev_int->wait); - }else -mutex_unlock (&ev_int->event_list_lock); +if (!test_bit (IIO_BUSY_BIT_POS , &ev_int->handler.flags)) + goto out_unlock; -error_ret: +if (ev_int->current_events == ev_int->max_events) + goto out_unlock; + + ev =kmalloc (sizeof (*ev),GFP_KERNEL ); +if (ev ==NULL ) { + ret = -ENOMEM ; + goto out_unlock; + } + + ev->ev.id = ev_code; + ev->ev.timestamp = timestamp; + ev->shared_pointer = shared_pointer_p; +if (ev->shared_pointer) + shared_pointer_p->ev_p = ev; + +list_add_tail (&ev->list, &ev_int->det_events.list); + ev_int->current_events++; +mutex_unlock (&ev_int->event_list_lock); +wake_up_interruptible (&ev_int->wait); + +return 0 ; + +out_unlock: +mutex_unlock (&ev_int->event_list_lock);return ret; }EXPORT_SYMBOL (__iio_push_event);
Signature · 1 line
1.6.3.3
Quoted 6 lines · Tobias Klauser
Correctly unlock the mutex when leaving the function. This was discovered by the stanse tool at
http://decibel.fi.muni.cz/~xslaby/stanse/error.cgi?db=33-rc&id=138Cc Jiri Slaby <[email protected]>Signed-off-by Tobias Klauser <[email protected]>
Sorry, but this is already fixed in my tree, someone beat you to it :)
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 6 lines · Tobias Klauser
Correctly unlock the mutex when leaving the function. This was discovered by the stanse tool at
http://decibel.fi.muni.cz/~xslaby/stanse/error.cgi?db=33-rc&id=138Cc Jiri Slaby <[email protected]>Signed-off-by Tobias Klauser <[email protected]>Sorry, but this is already fixed in my tree, someone beat you to it :)
Oh, I seem to have missed that one in linux-next (or I should have a closer look at your staging repository the next time :-). Never mind...
Cheers, Tobias