qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC] migration/dirtyrate: check malloc() return
@ 2022-04-10  3:58 jianchunfu
  2022-04-10  6:00 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: jianchunfu @ 2022-04-10  3:58 UTC (permalink / raw)
  To: quintela, dgilbert; +Cc: qemu-devel, jianchunfu

Handling potential memory allocation failures in dirtyrate.

Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
---
 migration/dirtyrate.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index aace12a787..5dd40f32c8 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -523,9 +523,17 @@ static void calculate_dirtyrate_dirty_ring(struct DirtyRateConfig config)
     }
 
     dirty_pages = malloc(sizeof(*dirty_pages) * nvcpu);
+    if (!dirty_pages) {
+        error_report("malloc dirty pages for vcpus failed.");
+        exit(1);
+    }
 
     DirtyStat.dirty_ring.nvcpu = nvcpu;
     DirtyStat.dirty_ring.rates = malloc(sizeof(DirtyRateVcpu) * nvcpu);
+    if (!DirtyStat.dirty_ring.rates) {
+        error_report("malloc dirty rates for vcpu ring failed.");
+        exit(1);
+    }
 
     dirtyrate_global_dirty_log_start();
 
-- 
2.18.4





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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-10  3:58 [RFC] migration/dirtyrate: check malloc() return jianchunfu
2022-04-10  6:00 ` Richard Henderson
2022-04-11 15:22   ` Alex Bennée

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).