From ba19783d9bd2e1d2e1c517b2bcb231c0a85aed54 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 23 Sep 2013 14:10:35 +0100 Subject: [PATCH] Fix crash on OOM in qemuDomainCCWAddressSetCreate() If OOM occurs in qemuDomainCCWAddressSetCreate, it jumps to a cleanup block and frees the partially initialized object. It then mistakenly returns the address of the just free'd pointer instead of NULL. Signed-off-by: Daniel P. Berrange --- src/qemu/qemu_command.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e6239c993c..e98aed5601 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1261,10 +1261,10 @@ qemuDomainCCWAddressSetCreate(void) qemuDomainCCWAddressSetPtr addrs = NULL; if (VIR_ALLOC(addrs) < 0) - goto cleanup; + goto error; if (!(addrs->defined = virHashCreate(10, qemuDomainCCWAddressSetFreeEntry))) - goto cleanup; + goto error; /* must use cssid = 0xfe (254) for virtio-ccw devices */ addrs->next.cssid = 254; @@ -1273,9 +1273,9 @@ qemuDomainCCWAddressSetCreate(void) addrs->next.assigned = 0; return addrs; -cleanup: +error: qemuDomainCCWAddressSetFree(addrs); - return addrs; + return NULL; } /*