[PATCH] phyp: Fix NULL dereference in phypConnectOpen

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

 



Coverity found out that commit cd490086 caused a possible NULL pointer
dereference.  This is due to the fact, that phyp_driver might be
NULL (if VIR_ALLOC() fails), but connection_data, which kept the socket
before the mentioned commit, could not be NULL.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/phyp/phyp_driver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 7c8bc5c..0d3ad53 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1222,6 +1222,7 @@ phypConnectOpen(virConnectPtr conn,
     if (phyp_driver != NULL) {
         virObjectUnref(phyp_driver->caps);
         virObjectUnref(phyp_driver->xmlopt);
+        VIR_FORCE_CLOSE(phyp_driver->sock);
         VIR_FREE(phyp_driver);
     }

@@ -1232,8 +1233,6 @@ phypConnectOpen(virConnectPtr conn,
         libssh2_session_free(session);
     }

-    VIR_FORCE_CLOSE(phyp_driver->sock);
-
     return VIR_DRV_OPEN_ERROR;
 }

-- 
2.1.3

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