summaryrefslogtreecommitdiffstats
path: root/nbd
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2017-12-07 16:50:57 +0100
committerEric Blake2018-01-09 19:53:44 +0100
commit9156245ec49b36d934ed09d49ffbd5dd37285374 (patch)
tree79136c40765a7a3c320f09d1e169af3d2476513e /nbd
parentMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-01-08' into st... (diff)
downloadqemu-9156245ec49b36d934ed09d49ffbd5dd37285374.tar.gz
qemu-9156245ec49b36d934ed09d49ffbd5dd37285374.tar.xz
qemu-9156245ec49b36d934ed09d49ffbd5dd37285374.zip
nbd/server: add additional assert to nbd_export_put
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 <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20171207155102.66622-2-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r--nbd/server.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/nbd/server.c b/nbd/server.c
index e443b3cf5c..6cf2eeb2c1 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);