From 6dba6be9f9b5e7e3c2e63e8be9c0eb0fbea16a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 23 Jun 2014 08:31:53 +0200 Subject: [PATCH] Properly check the return value of CCWAddressAsString It returns NULL on failure. Checking if the negation of it is less than zero makes no sense. (Found by coverity after moving the code) In another case, the return value wasn't checked at all. (cherry picked from commit 3fe9d75ab641f5b676845980a0ee7aef8148da9b) Conflicts: src/conf/domain_addr.c - no code movement from commit b2626755 --- src/qemu/qemu_command.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 763417fef1..ea7d01749b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1131,7 +1131,7 @@ int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, goto cleanup; } } else if (autoassign && !dev->addr.ccw.assigned) { - if (!(addr = qemuCCWAddressAsString(&addrs->next)) < 0) + if (!(addr = qemuCCWAddressAsString(&addrs->next))) goto cleanup; while (virHashLookup(addrs->defined, addr)) { @@ -1141,7 +1141,8 @@ int qemuDomainCCWAddressAssign(virDomainDeviceInfoPtr dev, goto cleanup; } VIR_FREE(addr); - addr = qemuCCWAddressAsString(&addrs->next); + if (!(addr = qemuCCWAddressAsString(&addrs->next))) + goto cleanup; } dev->addr.ccw = addrs->next; dev->addr.ccw.assigned = true;