[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/24] nbd: release exp->blk after all clients are cl
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 23/24] nbd: release exp->blk after all clients are closed |
Date: |
Wed, 16 Sep 2015 14:29:54 +0200 |
From: Wen Congyang <address@hidden>
If the socket fd is shutdown, there may be some data which is received before
shutdown. We will read the data and do read/write in nbd_trip(). But the exp's
blk is NULL, and it will cause qemu crashed.
Reported-by: Li Zhijian <address@hidden>
Signed-off-by: Wen Congyang <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
nbd.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/nbd.c b/nbd.c
index 06b501b..07240bd 100644
--- a/nbd.c
+++ b/nbd.c
@@ -1131,12 +1131,6 @@ void nbd_export_close(NBDExport *exp)
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
- if (exp->blk) {
- blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
- blk_aio_detach, exp);
- blk_unref(exp->blk);
- exp->blk = NULL;
- }
}
void nbd_export_get(NBDExport *exp)
@@ -1159,6 +1153,13 @@ void nbd_export_put(NBDExport *exp)
exp->close(exp);
}
+ if (exp->blk) {
+ blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
+ blk_aio_detach, exp);
+ blk_unref(exp->blk);
+ exp->blk = NULL;
+ }
+
g_free(exp);
}
}
@@ -1305,6 +1306,14 @@ static void nbd_trip(void *opaque)
goto invalid_request;
}
+ if (client->closing) {
+ /*
+ * The client may be closed when we are blocked in
+ * nbd_co_receive_request()
+ */
+ goto done;
+ }
+
switch (command) {
case NBD_CMD_READ:
TRACE("Request type is READ");
--
2.5.0
- [Qemu-devel] [PULL 15/24] tcg: split tcg_op_defs to -common, (continued)
- [Qemu-devel] [PULL 15/24] tcg: split tcg_op_defs to -common, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 09/24] monitor: remove target-specific code from monitor.c, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 18/24] cputlb: move CPU_LOOP() for tlb_reset() to exec.c, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 17/24] translate: move real_host_page setting to -common, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 19/24] cputlb: Change tlb_set_dirty() arg to cpu, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 21/24] monitor: uninclude cpu_ldst, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 24/24] Revert "rcu: init rcu_registry_lock after fork", Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 22/24] checkpatch: Escape left braces in regex, Paolo Bonzini, 2015/09/16
- [Qemu-devel] [PULL 23/24] nbd: release exp->blk after all clients are closed,
Paolo Bonzini <=
- [Qemu-devel] [PULL 20/24] include/exec: Move cputlb exec.c defs out, Paolo Bonzini, 2015/09/16
- Re: [Qemu-devel] [PULL 00/24] Misc patches for 2015-09-16, Eric Blake, 2015/09/16
- Re: [Qemu-devel] [PULL 00/24] Misc patches for 2015-09-16, Peter Maydell, 2015/09/16