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.
This commit is contained in:
Jim Meyering 2009-02-05 15:28:19 +00:00
parent 41549b3888
commit 7faa50d1db
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,10 @@
Wed Feb 4 22:22:34 +0100 2009 Jim Meyering <meyering@redhat.com>
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.
Tue Feb 3 14:06:06 +0100 2009 Jim Meyering <meyering@redhat.com> Tue Feb 3 14:06:06 +0100 2009 Jim Meyering <meyering@redhat.com>
avoid a format-related warning avoid a format-related warning

View File

@ -284,20 +284,20 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
} }
if ((rc = virFileMakePath(oldroot)) < 0) { if ((rc = virFileMakePath(oldroot)) < 0) {
VIR_FREE(oldroot);
virReportSystemError(NULL, rc, virReportSystemError(NULL, rc,
_("failed to create %s"), _("failed to create %s"),
oldroot); oldroot);
VIR_FREE(oldroot);
return -1; return -1;
} }
/* The old root directory will live at /.oldroot after /* The old root directory will live at /.oldroot after
* this and will soon be unmounted completely */ * this and will soon be unmounted completely */
if (pivot_root(root->src, oldroot) < 0) { if (pivot_root(root->src, oldroot) < 0) {
VIR_FREE(oldroot);
virReportSystemError(NULL, errno, virReportSystemError(NULL, errno,
_("failed to pivot root %s to %s"), _("failed to pivot root %s to %s"),
oldroot, root->src); oldroot, root->src);
VIR_FREE(oldroot);
return -1; return -1;
} }
VIR_FREE(oldroot); VIR_FREE(oldroot);
@ -677,4 +677,3 @@ int lxcContainerAvailable(int features)
return 0; return 0;
} }