ia64/xen-unstable

changeset 14209:d12432f31311

[xenstored] Fix error path when xc_map_foreign_range fails.
If xc_map_foreign_range fails, the new domain object is freed,
but it is not removed from the connection list.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Fri Mar 02 11:25:12 2007 +0000 (2007-03-02)
parents 139794d55898
children bb22c21e1af7
files tools/xenstore/xenstored_domain.c
line diff
     1.1 --- a/tools/xenstore/xenstored_domain.c	Thu Mar 01 17:59:17 2007 +0000
     1.2 +++ b/tools/xenstore/xenstored_domain.c	Fri Mar 02 11:25:12 2007 +0000
     1.3 @@ -320,6 +320,7 @@ void do_introduce(struct connection *con
     1.4  	unsigned long mfn;
     1.5  	evtchn_port_t port;
     1.6  	int rc;
     1.7 +	struct xenstore_domain_interface *interface;
     1.8  
     1.9  	if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) {
    1.10  		send_error(conn, EINVAL);
    1.11 @@ -344,19 +345,21 @@ void do_introduce(struct connection *con
    1.12  	domain = find_domain_by_domid(domid);
    1.13  
    1.14  	if (domain == NULL) {
    1.15 -		/* Hang domain off "in" until we're finished. */
    1.16 -		domain = new_domain(in, domid, port);
    1.17 -		if (!domain) {
    1.18 +		interface = xc_map_foreign_range(
    1.19 +			*xc_handle, domid,
    1.20 +			getpagesize(), PROT_READ|PROT_WRITE, mfn);
    1.21 +		if (!interface) {
    1.22  			send_error(conn, errno);
    1.23  			return;
    1.24  		}
    1.25 -		domain->interface = xc_map_foreign_range(
    1.26 -			*xc_handle, domid,
    1.27 -			getpagesize(), PROT_READ|PROT_WRITE, mfn);
    1.28 -		if (!domain->interface) {
    1.29 +		/* Hang domain off "in" until we're finished. */
    1.30 +		domain = new_domain(in, domid, port);
    1.31 +		if (!domain) {
    1.32 +			munmap(interface, getpagesize());
    1.33  			send_error(conn, errno);
    1.34  			return;
    1.35  		}
    1.36 +		domain->interface = interface;
    1.37  		domain->mfn = mfn;
    1.38  
    1.39  		/* Now domain belongs to its connection. */