[PATCH] virsh-nodedev: Avoid spurious errors

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

 



Our public free functions explicitly don't accept NULL pointers
(sigh). Therefore, callers must do something like this:

    if (dev)
        virNodeDeviceFree(dev);

And we are not doing that on two places I've found. This leads to
dummy error message thrown by virsh:

    virsh # nodedev-dumpxml nonexistent-device
    error: Could not find matching device 'nonexistent-device'
    error: invalid node device pointer in virNodeDeviceFree

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/virsh-nodedev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index a35387a..46e0045 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -162,7 +162,8 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
     ret = true;
  cleanup:
     virStringFreeList(arr);
-    virNodeDeviceFree(dev);
+    if (dev)
+        virNodeDeviceFree(dev);
     return ret;
 }
 
@@ -571,7 +572,8 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
  cleanup:
     virStringFreeList(arr);
     VIR_FREE(xml);
-    virNodeDeviceFree(device);
+    if (device)
+        virNodeDeviceFree(device);
     return ret;
 }
 
-- 
2.0.0

--
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]