[PATCH 3/3] qemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We should compare the alias/qdev id only when it was provided by the
caller and when it was found in the reply. Otherwise we could
dereference a NULL pointer. STRNEQ_NULLABLE is not appropriate since
it would return 'true' if the string was not present in the JSON output.

Found by Coverity.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 5cd38710e5..ddfa261743 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5001,8 +5001,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle,
             goto cleanup;
         }

-        if ((drivealias && STRNEQ(current_drive, drivealias)) ||
-            (qdevid && STRNEQ(current_qdev, qdevid)))
+        if ((drivealias && current_drive && STRNEQ(current_drive, drivealias)) ||
+            (qdevid && current_qdev && STRNEQ(current_qdev, qdevid)))
             continue;

         found = true;
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux