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

[libvirt] [PATCH] lxc: avoid null deref on lxcSetupLoopDevices failure



From: Alex Jia <ajia redhat com>

If the function lxcSetupLoopDevices(def, &nloopDevs, &loopDevs) failed, 
the variable loopDevs will keep a initial NULL value, however, the 
function VIR_FORCE_CLOSE(loopDevs[i]) will directly deref it.

* rc/lxc/lxc_controller.c: fixed a null pointer dereference.

Signed-off-by: Alex Jia <ajia redhat com>
---
 src/lxc/lxc_controller.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index c4e7832..024756d 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1017,8 +1017,11 @@ cleanup:
     VIR_FORCE_CLOSE(containerhandshake[0]);
     VIR_FORCE_CLOSE(containerhandshake[1]);
 
-    for (i = 0 ; i < nloopDevs ; i++)
-        VIR_FORCE_CLOSE(loopDevs[i]);
+    if (loopDevs) {
+        for (i = 0 ; i < nloopDevs ; i++)
+            VIR_FORCE_CLOSE(loopDevs[i]);
+    }
+
     VIR_FREE(loopDevs);
 
     if (container > 1) {
-- 
1.7.1


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