提交 7faa50d1 编写于 作者: J Jim Meyering

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.
上级 41549b38
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
......
...@@ -284,20 +284,20 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) ...@@ -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) ...@@ -677,4 +677,3 @@ int lxcContainerAvailable(int features)
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册