From 289a3163de9378ea5c7321ac44b7b34bf4806ea5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 2 Jun 2014 16:48:22 +0200 Subject: [PATCH] virsh-nodedev: Avoid spurious errors 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 --- 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 a35387a3ba..46e0045270 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.39.5