[PATCH] I2O: handle a few sysfs errors
authorJeff Garzik <jeff@garzik.org>
Tue, 17 Oct 2006 07:10:22 +0000 (00:10 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 17 Oct 2006 15:18:46 +0000 (08:18 -0700)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/message/i2o/bus-osm.c
drivers/message/i2o/exec-osm.c

index ac06f10c54ec1416c1a9b75fdbde20e23051be22..d96c687aee9373fe7638fa61bb88e335b58b65ea 100644 (file)
@@ -80,18 +80,26 @@ static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
  *     @dev: device to verify if it is a I2O Bus Adapter device
  *
  *     Because we want all Bus Adapters always return 0.
+ *     Except when we fail.  Then we are sad.
  *
- *     Returns 0.
+ *     Returns 0, except when we fail to excel.
  */
 static int i2o_bus_probe(struct device *dev)
 {
        struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
+       int rc;
 
-       device_create_file(dev, &dev_attr_scan);
+       rc = device_create_file(dev, &dev_attr_scan);
+       if (rc)
+               goto err_out;
 
        osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
 
        return 0;
+
+err_out:
+       put_device(dev);
+       return rc;
 };
 
 /**
index 7bd4d85d0b42db6af28def4072cbd11fbadbec86..91f95d172ca54097a0b2b14d767b11aa179fed74 100644 (file)
@@ -325,13 +325,24 @@ static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
 static int i2o_exec_probe(struct device *dev)
 {
        struct i2o_device *i2o_dev = to_i2o_device(dev);
+       int rc;
 
-       i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
+       rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
+       if (rc) goto err_out;
 
-       device_create_file(dev, &dev_attr_vendor_id);
-       device_create_file(dev, &dev_attr_product_id);
+       rc = device_create_file(dev, &dev_attr_vendor_id);
+       if (rc) goto err_evtreg;
+       rc = device_create_file(dev, &dev_attr_product_id);
+       if (rc) goto err_vid;
 
        return 0;
+
+err_vid:
+       device_remove_file(dev, &dev_attr_vendor_id);
+err_evtreg:
+       i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
+err_out:
+       return rc;
 };
 
 /**