# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID d3c0d85b7ef8c613e41a08caf8ced338671146b6
# Parent 6b94eaa59279b2a3a5917779f42b58abcd3478c3
Unregister watch in error path.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
diff -r 6b94eaa59279 -r d3c0d85b7ef8
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Aug 24 20:11:07 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Aug 24 20:29:42 2005
@@ -201,20 +201,7 @@
xenbus_dev_error(dev, -ENOMEM, "allocating backend structure");
return -ENOMEM;
}
-
memset(be, 0, sizeof(*be));
-
- be->dev = dev;
- be->backend_watch.node = dev->nodename;
- be->backend_watch.callback = backend_changed;
- err = register_xenbus_watch(&be->backend_watch);
- if (err) {
- xenbus_dev_error(dev, err, "adding backend watch on %s",
- dev->nodename);
- goto free_be;
- }
-
- dev->data = be;
frontend = NULL;
err = xenbus_gather(dev->nodename,
@@ -223,17 +210,28 @@
NULL);
if (XENBUS_EXIST_ERR(err))
goto free_be;
- if (frontend &&
- (strlen(frontend) == 0 || !xenbus_exists(frontend, ""))) {
+ if (err < 0) {
+ xenbus_dev_error(dev, err,
+ "reading %s/frontend or frontend-id",
+ dev->nodename);
+ goto free_be;
+ }
+ if (strlen(frontend) == 0 || !xenbus_exists(frontend, "")) {
/* If we can't get a frontend path and a frontend-id,
* then our bus-id is no longer valid and we need to
* destroy the backend device.
*/
- goto free_be;
- }
- if (err < 0) {
- xenbus_dev_error(dev, err,
- "reading %s/frontend or frontend-id",
+ err = -ENOENT;
+ goto free_be;
+ }
+
+ be->dev = dev;
+ be->backend_watch.node = dev->nodename;
+ be->backend_watch.callback = backend_changed;
+ err = register_xenbus_watch(&be->backend_watch);
+ if (err) {
+ be->backend_watch.node = NULL;
+ xenbus_dev_error(dev, err, "adding backend watch on %s",
dev->nodename);
goto free_be;
}
@@ -250,10 +248,14 @@
goto free_be;
}
+ dev->data = be;
+
backend_changed(&be->backend_watch, dev->nodename);
- return err;
+ return 0;
free_be:
+ if (be->backend_watch.node)
+ unregister_xenbus_watch(&be->backend_watch);
if (frontend)
kfree(frontend);
kfree(be);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|