ia64/xen-unstable

changeset 6400:d3c0d85b7ef8

Unregister watch in error path.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Aug 24 20:29:42 2005 +0000 (2005-08-24)
parents 6b94eaa59279
children 4ab607ca02c3
files linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Wed Aug 24 20:11:07 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Wed Aug 24 20:29:42 2005 +0000
     1.3 @@ -201,21 +201,8 @@ static int blkback_probe(struct xenbus_d
     1.4  		xenbus_dev_error(dev, -ENOMEM, "allocating backend structure");
     1.5  		return -ENOMEM;
     1.6  	}
     1.7 -
     1.8  	memset(be, 0, sizeof(*be));
     1.9  
    1.10 -	be->dev = dev;
    1.11 -	be->backend_watch.node = dev->nodename;
    1.12 -	be->backend_watch.callback = backend_changed;
    1.13 -	err = register_xenbus_watch(&be->backend_watch);
    1.14 -	if (err) {
    1.15 -		xenbus_dev_error(dev, err, "adding backend watch on %s",
    1.16 -				 dev->nodename);
    1.17 -		goto free_be;
    1.18 -	}
    1.19 -
    1.20 -	dev->data = be;
    1.21 -
    1.22  	frontend = NULL;
    1.23  	err = xenbus_gather(dev->nodename,
    1.24  			    "frontend-id", "%li", &be->frontend_id,
    1.25 @@ -223,17 +210,28 @@ static int blkback_probe(struct xenbus_d
    1.26  			    NULL);
    1.27  	if (XENBUS_EXIST_ERR(err))
    1.28  		goto free_be;
    1.29 -	if (frontend &&
    1.30 -	    (strlen(frontend) == 0 || !xenbus_exists(frontend, ""))) {
    1.31 +	if (err < 0) {
    1.32 +		xenbus_dev_error(dev, err,
    1.33 +				 "reading %s/frontend or frontend-id",
    1.34 +				 dev->nodename);
    1.35 +		goto free_be;
    1.36 +	}
    1.37 +	if (strlen(frontend) == 0 || !xenbus_exists(frontend, "")) {
    1.38  		/* If we can't get a frontend path and a frontend-id,
    1.39  		 * then our bus-id is no longer valid and we need to
    1.40  		 * destroy the backend device.
    1.41  		 */
    1.42 +		err = -ENOENT;
    1.43  		goto free_be;
    1.44  	}
    1.45 -	if (err < 0) {
    1.46 -		xenbus_dev_error(dev, err,
    1.47 -				 "reading %s/frontend or frontend-id",
    1.48 +
    1.49 +	be->dev = dev;
    1.50 +	be->backend_watch.node = dev->nodename;
    1.51 +	be->backend_watch.callback = backend_changed;
    1.52 +	err = register_xenbus_watch(&be->backend_watch);
    1.53 +	if (err) {
    1.54 +		be->backend_watch.node = NULL;
    1.55 +		xenbus_dev_error(dev, err, "adding backend watch on %s",
    1.56  				 dev->nodename);
    1.57  		goto free_be;
    1.58  	}
    1.59 @@ -250,10 +248,14 @@ static int blkback_probe(struct xenbus_d
    1.60  		goto free_be;
    1.61  	}
    1.62  
    1.63 +	dev->data = be;
    1.64 +
    1.65  	backend_changed(&be->backend_watch, dev->nodename);
    1.66 -	return err;
    1.67 +	return 0;
    1.68  
    1.69   free_be:
    1.70 +	if (be->backend_watch.node)
    1.71 +		unregister_xenbus_watch(&be->backend_watch);
    1.72  	if (frontend)
    1.73  		kfree(frontend);
    1.74  	kfree(be);