From: Kaifeng Zhu Date: Fri, 7 Mar 2014 15:16:42 +0000 (+0000) Subject: hw/device-hotplug: fix test of drive_add() return X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=2c69a0bb9e3b96bb041abf221323599976a4760c;p=qemu-xen-4.6-testing.git hw/device-hotplug: fix test of drive_add() return 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 Coverity-ID: 1055574 Reviewed-by: Andrew Cooper --- diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 3bdc048c6..97d352993 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -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);