struct gb_operation *operation;
        struct gb_message *message;
        struct gb_operation_msg_hdr *header;
+       int result;
 
        operation = gb_pending_operation_find(connection, operation_id);
        if (!operation) {
        if (size <= message->size) {
                /* Transfer the operation result from the response header */
                header = message->header;
-               operation->errno = gb_operation_status_map(header->result);
+               result = gb_operation_status_map(header->result);
        } else {
                gb_connection_err(connection, "recv buffer too small");
-               operation->errno = -E2BIG;
+               result = -E2BIG;
        }
 
        /* We must ignore the payload if a bad status is returned */
-       if (!operation->errno)
+       if (!result)
                memcpy(message->header, data, size);
 
        /* The rest will be handled in work queue context */
+       operation->errno = result;
        queue_work(gb_operation_workqueue, &operation->work);
 }