[libvirt] [PATCH] lxc_container: Don't dereference NULL upon failure (x2)

Spotted these while skimming through all VIR_FREE uses.
From af9e606d97e8321683ba765ba0a4af4c065d3b4b Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 4 Feb 2009 18:44:34 +0100 Subject: [PATCH] lxc_container: Don't dereference NULL upon failure
* src/lxc_container.c (lxcContainerPivotRoot): Free and zero oldroot *after* printing the diagnostic, both for virFileMakePath and pivot_root failure. --- src/lxc_container.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lxc_container.c b/src/lxc_container.c index ea52eed..90c70d5 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -284,20 +284,20 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } if ((rc = virFileMakePath(oldroot)) < 0) { - VIR_FREE(oldroot); virReportSystemError(NULL, rc, _("failed to create %s"), oldroot); + VIR_FREE(oldroot); return -1; } /* The old root directory will live at /.oldroot after * this and will soon be unmounted completely */ if (pivot_root(root->src, oldroot) < 0) { - VIR_FREE(oldroot); virReportSystemError(NULL, errno, _("failed to pivot root %s to %s"), oldroot, root->src); + VIR_FREE(oldroot); return -1; } VIR_FREE(oldroot); @@ -677,4 +677,3 @@ int lxcContainerAvailable(int features) return 0; } - -- 1.6.1.2.467.g081e7

On Wed, Feb 04, 2009 at 06:49:23PM +0100, Jim Meyering wrote:
Spotted these while skimming through all VIR_FREE uses.
From af9e606d97e8321683ba765ba0a4af4c065d3b4b Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Wed, 4 Feb 2009 18:44:34 +0100 Subject: [PATCH] lxc_container: Don't dereference NULL upon failure
* src/lxc_container.c (lxcContainerPivotRoot): Free and zero oldroot *after* printing the diagnostic, both for virFileMakePath and pivot_root failure.
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Jim Meyering