From fac1a19dfca0a8bc2cb618e0b96119fd3dd07e55 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 26 Nov 2012 12:13:56 +0100 Subject: [PATCH] lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths Early jumps to the cleanup label caused a crash of the libvirt_lxc container helper as the cleanup section called virLXCControllerDeleteInterfaces(ctrl) without checking the ctrl argument for NULL. The argument was de-referenced soon after. $ /usr/libexec/libvirt_lxc /usr/libexec/libvirt_lxc: missing --name argument for configuration Segmentation fault (cherry picked from commit 81efb13b4a33f58c28e0e65dcc9521b983592683) --- src/lxc/lxc_controller.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 6ff2e4643d..2807f3559a 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1649,7 +1649,8 @@ int main(int argc, char *argv[]) cleanup: virPidFileDelete(LXC_STATE_DIR, name); - virLXCControllerDeleteInterfaces(ctrl); + if (ctrl) + virLXCControllerDeleteInterfaces(ctrl); for (i = 0 ; i < nttyFDs ; i++) VIR_FORCE_CLOSE(ttyFDs[i]); VIR_FREE(ttyFDs);