mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
init-xenstore-domain: cleanup all resources on a single exit path
Previously xs_fd would be left open, which is CID 1055993 (previously
partially fixed by 3bca826aae).
Instead arrange for both success and error cases to cleanup everything
on a single exit path instead of doing partial cleanup on the success
path a few operations higher up.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
This commit is contained in:
1 parent
8b00908c11
commit
f15348afe9
1 file changed
+7
-6
@@ -172,9 +172,6 @@ static int build(xc_interface *xch)
|
||||
goto err;
|
||||
}
|
||||
|
||||
xc_dom_release(dom);
|
||||
dom = NULL;
|
||||
|
||||
rv = xc_domain_set_virq_handler(xch, domid, VIRQ_DOM_EXC);
|
||||
if ( rv )
|
||||
{
|
||||
@@ -188,14 +185,18 @@ static int build(xc_interface *xch)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
rv = 0;
|
||||
|
||||
err:
|
||||
if ( dom )
|
||||
xc_dom_release(dom);
|
||||
if ( domid != ~0 )
|
||||
if ( xs_fd >= 0 )
|
||||
close(xs_fd);
|
||||
|
||||
/* if we failed then destroy the domain */
|
||||
if ( rv && domid != ~0 )
|
||||
xc_domain_destroy(xch, domid);
|
||||
close(xs_fd);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||