On 16/09/2015 10:22, Wen Congyang wrote: >>> >> if (exp->blk) { >>> >> + bdrv_drain(blk_bs(exp->blk)); >>> >> blk_remove_aio_context_notifier(exp->blk, blk_aio_attached, >>> >> blk_aio_detach, exp); >>> >> blk_unref(exp->blk); >> > >> > I think a better fix is to move the whole "if" to nbd_export_put. In >> > fact, nbd_export_close is wrong because exp can be freed by >> > nbd_export_close's call to nbd_export_put. > OK, I will fix it in the next version.
To be clear, the bug is pre-existing (commit 38b54b6, "nbd: use BlockDriverState refcnt", 2013-08-23). Paolo