From f5a6ce44ce8368d4183b69a31b77f67688d9af43 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 2 Mar 2010 17:45:10 +0100 Subject: [PATCH] qemudDomainAttachSCSIDisk: handle empty controller list * src/qemu/qemu_driver.c (qemudDomainAttachSCSIDisk): Handle the (theoretical) case of an empty controller list, so that clang does not think the subsequent dereference of "cont" would dereference an undefined variable (due to preceding loop not iterating even once). --- src/qemu/qemu_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c6991b50eb..79899e5b4e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6090,6 +6090,12 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver, if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags))) goto error; + if (disk->info.addr.drive.controller <= 0) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("no drive controller for %s"), disk->dst); + goto error; + } + for (i = 0 ; i <= disk->info.addr.drive.controller ; i++) { cont = qemuDomainFindOrCreateSCSIDiskController(driver, vm, i, qemuCmdFlags); if (!cont)