[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1263547801-8640-1-git-send-email-tklauser@distanz.ch>
Date: Fri, 15 Jan 2010 10:30:01 +0100
From: Tobias Klauser <tklauser@...tanz.ch>
To: Greg Kroah-Hartman <gregkh@...e.de>, devel@...verdev.osuosl.org
Cc: linux-kernel@...r.kernel.org, Tobias Klauser <tklauser@...tanz.ch>,
Jiri Slaby <jirislaby@...il.com>
Subject: [PATCH] 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
Cc: Jiri Slaby <jirislaby@...il.com>
Signed-off-by: Tobias Klauser <tklauser@...tanz.ch>
---
drivers/staging/iio/industrialio-core.c | 49 +++++++++++++++++--------------
1 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index 768f448..fa0f025 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -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);
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists