All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/nvme: fix control flow statement
@ 2022-04-15 19:27 Dmitry Tikhov
  2022-04-15 19:35 ` Keith Busch
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Tikhov @ 2022-04-15 19:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: kbusch, its, ddtikhov, qemu-block, linux

Since there is no else after nvme_dsm_cb invocation, metadata associated
with non-zero block range is currently zeroed. Also this behaviour leads
to segfault since we schedule iocb->bh two times. First when entering
nvme_dsm_cb with iocb->idx == iocb->nr and second on call stack unwinding
by calling blk_aio_pwrite_zeroes and subsequent nvme_dsm_cb callback
because of missing else statement.

Signed-off-by: Dmitry Tikhov <d.tihov@yadro.com>
---
 hw/nvme/ctrl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 03760ddeae..7ebd2aa326 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -2372,11 +2372,12 @@ static void nvme_dsm_md_cb(void *opaque, int ret)
         }
 
         nvme_dsm_cb(iocb, 0);
+    } else {
+        iocb->aiocb = blk_aio_pwrite_zeroes(ns->blkconf.blk, nvme_moff(ns, slba),
+                                            nvme_m2b(ns, nlb), BDRV_REQ_MAY_UNMAP,
+                                            nvme_dsm_cb, iocb);
     }
 
-    iocb->aiocb = blk_aio_pwrite_zeroes(ns->blkconf.blk, nvme_moff(ns, slba),
-                                        nvme_m2b(ns, nlb), BDRV_REQ_MAY_UNMAP,
-                                        nvme_dsm_cb, iocb);
     return;
 
 done:
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-15 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 19:27 [PATCH] hw/nvme: fix control flow statement Dmitry Tikhov
2022-04-15 19:35 ` Keith Busch
2022-04-15 19:42   ` Klaus Jensen
2022-04-15 20:23     ` Dmitry Tikhov
2022-04-15 20:27       ` Klaus Jensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.