aboutsummaryrefslogtreecommitdiff
path: root/migration/ram.c
diff options
context:
space:
mode:
authorDmitry Frolov <frolov@swemel.ru>2023-10-10 13:48:53 +0300
committerJuan Quintela <quintela@redhat.com>2023-10-17 09:14:32 +0200
commitf75ed59f40bed3ce94adad4b3ebbb7bfacfdf4ab (patch)
treedc94543f961b774fd08a9b94cbc078b47e239881 /migration/ram.c
parent8b2395970aa3beab91b98dda89c7ed471e65ad25 (diff)
downloadqemu-f75ed59f40bed3ce94adad4b3ebbb7bfacfdf4ab.zip
qemu-f75ed59f40bed3ce94adad4b3ebbb7bfacfdf4ab.tar.gz
qemu-f75ed59f40bed3ce94adad4b3ebbb7bfacfdf4ab.tar.bz2
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. 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>
Diffstat (limited to 'migration/ram.c')
-rw-r--r--migration/ram.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/migration/ram.c b/migration/ram.c
index 24d91de..e8df4dc 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -4285,6 +4285,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 (migrate_ram_is_ignored(rb)) {
return;
}