connection: add extra ref to reply while operating on it
authorDaniel Mack <daniel@zonque.org>
Thu, 8 Jan 2015 18:58:31 +0000 (19:58 +0100)
committerDaniel Mack <daniel@zonque.org>
Thu, 8 Jan 2015 18:58:31 +0000 (19:58 +0100)
kdbus_reply_unlink() potentially destroys the reply, so keep an
extra reference while working with it. Drop the reference after
we're done.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection.c

index 19a41dcc65c83b91df1c3ea57a3eeda719ae0059..87f90b39153bc8ccb89b10a9610498d470d4a6a6 100644 (file)
@@ -150,7 +150,7 @@ int kdbus_cmd_msg_recv(struct kdbus_conn *conn,
 
        /* just drop the message */
        if (recv->flags & KDBUS_RECV_DROP) {
-               struct kdbus_reply *reply = entry->reply;
+               struct kdbus_reply *reply = kdbus_reply_ref(entry->reply);
 
                kdbus_queue_entry_remove(conn, entry);
                kdbus_pool_slice_release(entry->slice);
@@ -178,6 +178,7 @@ int kdbus_cmd_msg_recv(struct kdbus_conn *conn,
 
                kdbus_notify_flush(conn->ep->bus);
                kdbus_queue_entry_free(entry);
+               kdbus_reply_unref(reply);
 
                return 0;
        }