From: David Herrmann Date: Thu, 8 Jan 2015 23:36:38 +0000 (+0100) Subject: connection: fix kdbus_conn_lock2() for A==B X-Git-Tag: upstream/0.20150129.081441utc~61 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5dcd2bbbde7ae25c6d018a3966d7853d8faece1c;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git connection: fix kdbus_conn_lock2() for A==B In odd cases (eg., sending a message to yourself), you might call kdbus_conn_lock2() with A==B. Make sure we lock the connection only once to not dead-lock. Signed-off-by: David Herrmann --- diff --git a/connection.h b/connection.h index 413b780..5ef557b 100644 --- a/connection.h +++ b/connection.h @@ -218,6 +218,9 @@ static inline int kdbus_conn_is_monitor(const struct kdbus_conn *conn) */ static inline void kdbus_conn_lock2(struct kdbus_conn *a, struct kdbus_conn *b) { + if (a == b) + b = NULL; + if (a < b) { if (a) mutex_lock(&a->lock); @@ -241,6 +244,9 @@ static inline void kdbus_conn_lock2(struct kdbus_conn *a, struct kdbus_conn *b) static inline void kdbus_conn_unlock2(struct kdbus_conn *a, struct kdbus_conn *b) { + if (a == b) + b = NULL; + if (a) mutex_unlock(&a->lock); if (b)