connection: for KDBUS_MSG_SIGNAL check match db then the policy db
authorDjalal Harouni <tixxdz@opendz.org>
Mon, 5 Jan 2015 19:33:56 +0000 (20:33 +0100)
committerDjalal Harouni <tixxdz@opendz.org>
Mon, 5 Jan 2015 19:33:56 +0000 (20:33 +0100)
Minor optimization, before locking the endpoint policy db in order to
check for TALK access, check first that the destination match db is
interested in the signal.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
connection.c

index 9b016d5f97a4c88bdc4ec6c84de320cabbedc747..2fcf813ae25b88422535d0c2760f3e1a7fb6784b 100644 (file)
@@ -1001,6 +1001,12 @@ int kdbus_cmd_msg_send(struct kdbus_conn *conn_src,
                                goto exit_unref;
                        }
                } else if (msg->flags & KDBUS_MSG_SIGNAL) {
+                       if (!kdbus_match_db_match_kmsg(conn_dst->match_db,
+                                                      conn_src, kmsg)) {
+                               ret = -EPERM;
+                               goto exit_unref;
+                       }
+
                        /*
                         * A receiver needs TALK access to the sender
                         * in order to receive signals.
@@ -1009,12 +1015,6 @@ int kdbus_cmd_msg_send(struct kdbus_conn *conn_src,
                                                      msg, NULL);
                        if (ret < 0)
                                goto exit_unref;
-
-                       if (!kdbus_match_db_match_kmsg(conn_dst->match_db,
-                                                      conn_src, kmsg)) {
-                               ret = -EPERM;
-                               goto exit_unref;
-                       }
                } else {
                        ret = kdbus_conn_check_access(conn_src, conn_dst,
                                                      msg, &reply_wake);