42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
|
|
From 03569a14e7ae428bad59a4e11637c900ff436816 Mon Sep 17 00:00:00 2001
|
||
|
|
From: jipengfei <jipengfei_yewu@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 18 Dec 2023 16:56:15 +0800
|
||
|
|
Subject: [PATCH] migration: fix RAMBlock add NULL check
|
||
|
|
|
||
|
|
qemu_ram_block_from_host() may return NULL, which will be dereferenced w/o
|
||
|
|
check. Usualy return value is checked for this function.
|
||
|
|
Found by Linux Verification Center (linuxtesting.org) with SVACE.
|
||
|
|
|
||
|
|
cheery-pick from f75ed59f40bed3ce94adad4b3ebbb7bfacfdf4ab
|
||
|
|
|
||
|
|
Signed-off-by: jipengfei_yewu <jipengfei_yewu@cmss.chinamobile.com>
|
||
|
|
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
|
||
|
|
Reviewed-by: Fabiano Rosas <farosas@suse.de>
|
||
|
|
Reviewed-by: Peter Xu <peterx@redhat.com>
|
||
|
|
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
||
|
|
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
||
|
|
Message-ID: <20231010104851.802947-1-frolov@swemel.ru>
|
||
|
|
---
|
||
|
|
migration/ram.c | 5 +++++
|
||
|
|
1 file changed, 5 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/migration/ram.c b/migration/ram.c
|
||
|
|
index 862955f5b2..c245b04cf2 100644
|
||
|
|
--- a/migration/ram.c
|
||
|
|
+++ b/migration/ram.c
|
||
|
|
@@ -4679,6 +4679,11 @@ static void ram_mig_ram_block_resized(RAMBlockNotifier *n, void *host,
|
||
|
|
RAMBlock *rb = qemu_ram_block_from_host(host, false, &offset);
|
||
|
|
Error *err = NULL;
|
||
|
|
|
||
|
|
+ if (!rb) {
|
||
|
|
+ error_report("RAM block not found");
|
||
|
|
+ return;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
if (ramblock_is_ignored(rb)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|