xen: xenbus: Catch closing of non existent transactions
authorSimon Gaiser <simon@invisiblethingslab.com>
Thu, 15 Mar 2018 02:43:21 +0000 (03:43 +0100)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Wed, 21 Mar 2018 12:28:51 +0000 (08:28 -0400)
Users of the xenbus functions should never close a non existent
transaction (for example by trying to closing the same transaction
twice) but better catch it in xs_request_exit() than to corrupt the
reference counter.

Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/xen/xenbus/xenbus_xs.c

index 3f3b29398ab8e2b711ce724cf756ea8c241433cb..49a3874ae6bb45e2c5031fa183a252d78e8d882f 100644 (file)
@@ -140,7 +140,9 @@ void xs_request_exit(struct xb_req_data *req)
        spin_lock(&xs_state_lock);
        xs_state_users--;
        if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) ||
-           req->type == XS_TRANSACTION_END)
+           (req->type == XS_TRANSACTION_END &&
+            !WARN_ON_ONCE(req->msg.type == XS_ERROR &&
+                          !strcmp(req->body, "ENOENT"))))
                xs_state_users--;
        spin_unlock(&xs_state_lock);