connection: update attach_flags only if KDBUS_ITEM_ATTACH_FLAGS is provided
authorDjalal Harouni <tixxdz@opendz.org>
Fri, 20 Jun 2014 16:50:00 +0000 (17:50 +0100)
committerDaniel Mack <zonque@gmail.com>
Fri, 20 Jun 2014 17:10:14 +0000 (19:10 +0200)
Fix a bug introcuded in commit d92d68414fab which fixed another bug.

conn->attach_flags should only be update if KDBUS_ITEM_ATTACH_FLAGS was
provided.

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

index 3e8c5de0773dfb41ee23da486bd6f64573847067..542f6773847105c43fe3b4426ac26634ed83e4a6 100644 (file)
@@ -1784,6 +1784,7 @@ int kdbus_cmd_conn_update(struct kdbus_conn *conn,
 {
        const struct kdbus_item *item;
        bool policy_provided = false;
+       bool flags_provided = false;
        u64 attach_flags = 0;
        int ret;
 
@@ -1795,6 +1796,7 @@ int kdbus_cmd_conn_update(struct kdbus_conn *conn,
 
                switch (item->type) {
                case KDBUS_ITEM_ATTACH_FLAGS:
+                       flags_provided = true;
                        attach_flags = item->data64[0];
                        break;
                case KDBUS_ITEM_NAME:
@@ -1807,7 +1809,8 @@ int kdbus_cmd_conn_update(struct kdbus_conn *conn,
        if (!KDBUS_ITEMS_END(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items)))
                return -EINVAL;
 
-       conn->attach_flags = attach_flags;
+       if (flags_provided)
+               conn->attach_flags = attach_flags;
 
        if (!policy_provided)
                return 0;