]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix potential false-positive OOM error reporting.
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 21 Oct 2009 20:27:09 +0000 (22:27 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 22 Oct 2009 13:25:45 +0000 (15:25 +0200)
If no matching device was found (cap == NULL) then no strdup() call
was made and *wwnn and *wwpn are untouched. Checking them for NULL
in this situation may result in reporting an false-positive OOM error
because *wwnn and *wwpn may be initialized to NULL by the caller.

Only check *wwnn and *wwpn for NULL if a matching device was found
(cap != NULL) and thus strdup() was called.

* src/conf/node_device_conf.c: only report an OOM error if there
  really is one

src/conf/node_device_conf.c

index 77f7be31ed87ad50bfd70b363309a17035ef35b2..c2c5a44438f561cff224268e688ae38cb072d3ca 100644 (file)
@@ -1243,9 +1243,7 @@ virNodeDeviceGetWWNs(virConnectPtr conn,
         virNodeDeviceReportError(conn, VIR_ERR_NO_SUPPORT,
                                  "%s", _("Device is not a fibre channel HBA"));
         ret = -1;
-    }
-
-    if (*wwnn == NULL || *wwpn == NULL) {
+    } else if (*wwnn == NULL || *wwpn == NULL) {
         /* Free the other one, if allocated... */
         VIR_FREE(wwnn);
         VIR_FREE(wwpn);