qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/monitor: blk_bs() return value check
@ 2023-11-24 11:30 Dmitry Frolov
  2023-11-24 13:06 ` Kevin Wolf
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Frolov @ 2023-11-24 11:30 UTC (permalink / raw)
  To: kwolf, hreitz, qemu-block; +Cc: sdl.qemu, qemu-devel, Dmitry Frolov

blk_bs() may return NULL, which will be dereferenced without a check in
bdrv_commit().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
---
 block/monitor/block-hmp-cmds.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index c729cbf1eb..ade627bc27 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -221,7 +221,13 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
             return;
         }
 
-        bs = bdrv_skip_implicit_filters(blk_bs(blk));
+        bs = blk_bs(blk);
+        if (!bs) {
+            error_report("Device '%s' is invalid", device);
+            return;
+        }
+
+        bs = bdrv_skip_implicit_filters(bs);
         aio_context = bdrv_get_aio_context(bs);
         aio_context_acquire(aio_context);
 
-- 
2.34.1



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

end of thread, other threads:[~2023-11-24 16:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-24 11:30 [PATCH] block/monitor: blk_bs() return value check Dmitry Frolov
2023-11-24 13:06 ` Kevin Wolf
2023-11-24 14:05   ` Дмитрий Фролов
2023-11-24 16:49     ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).