]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemudDomainAttachSCSIDisk: handle empty controller list
authorJim Meyering <meyering@redhat.com>
Tue, 2 Mar 2010 16:45:10 +0000 (17:45 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 5 Mar 2010 17:42:30 +0000 (18:42 +0100)
* 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

index c6991b50eb916e2ff2ce97428e71ad31c6739ab1..79899e5b4ef984178abf03583a55afdcd9105e53 100644 (file)
@@ -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)