]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commitdiff
hw/device-hotplug: fix test of drive_add() return
authorKaifeng Zhu <kaifeng.zhu@citrix.com>
Fri, 7 Mar 2014 15:16:42 +0000 (15:16 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Oct 2015 15:52:06 +0000 (16:52 +0100)
drive_opt_idx could be -1 in case error occurs inside drive_add, so the error
check should be "if (drive_opt_idx < 0)" instead of original
"if (!drive_opt_idx)".

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@citrix.com>
Coverity-ID: 1055574
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
hw/device-hotplug.c

index 3bdc048c685031b690526bbb6cc1fb3c6667bb16..97d3529938b328f02f4650db9ebe8b95fd71cd28 100644 (file)
@@ -34,7 +34,7 @@ int add_init_drive(const char *opts)
     int ret = -1;
 
     drive_opt_idx = drive_add(NULL, "%s", opts);
-    if (!drive_opt_idx)
+    if (drive_opt_idx < 0)
         return ret;
 
     drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine);