[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 1/6] nbd/server: add additional assert to nbd_exp
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v2 1/6] nbd/server: add additional assert to nbd_export_put |
Date: |
Thu, 7 Dec 2017 18:50:57 +0300 |
This place is not obvious, nbd_export_close may theoretically reduce
refcount to 0. It may happen if someone calls nbd_export_put on named
export not through nbd_export_set_name when refcount is 1.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
nbd/server.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/nbd/server.c b/nbd/server.c
index 92c0fdd03b..e817c48087 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1190,6 +1190,12 @@ void nbd_export_put(NBDExport *exp)
nbd_export_close(exp);
}
+ /* nbd_export_close() may theoretically reduce refcount to 0. It may happen
+ * if someone calls nbd_export_put() on named export not through
+ * nbd_export_set_name() when refcount is 1. So, let's assert that
+ * it is > 0.
+ */
+ assert(exp->refcount > 0);
if (--exp->refcount == 0) {
assert(exp->name == NULL);
assert(exp->description == NULL);
--
2.11.1
- [Qemu-block] [PATCH v2 0/6] nbd export qmp interface, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] [PATCH v2 1/6] nbd/server: add additional assert to nbd_export_put,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH v2 6/6] iotest 201: new test for qmp nbd-server-remove, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] [PATCH v2 5/6] iotests: implement QemuIoInteractive class, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] [PATCH v2 4/6] iotest 147: add cases to test new @name parameter of nbd-server-add, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] [PATCH v2 3/6] qapi: add nbd-server-remove, Vladimir Sementsov-Ogievskiy, 2017/12/07
- [Qemu-block] ping Re: [PATCH v2 0/6] nbd export qmp interface, Vladimir Sementsov-Ogievskiy, 2017/12/21
- Re: [Qemu-block] [Qemu-devel] [PATCH v2 0/6] nbd export qmp interface, Markus Armbruster, 2017/12/21