driver core: Fix unbalanced device reference in drivers_probe
[pandora-kernel.git] / drivers / base / bus.c
index 8b8e8c0..b802cfc 100644 (file)
@@ -240,13 +240,15 @@ static ssize_t store_drivers_probe(struct bus_type *bus,
                                   const char *buf, size_t count)
 {
        struct device *dev;
                                   const char *buf, size_t count)
 {
        struct device *dev;
+       int err = -EINVAL;
 
        dev = bus_find_device_by_name(bus, NULL, buf);
        if (!dev)
                return -ENODEV;
 
        dev = bus_find_device_by_name(bus, NULL, buf);
        if (!dev)
                return -ENODEV;
-       if (bus_rescan_devices_helper(dev, NULL) != 0)
-               return -EINVAL;
-       return count;
+       if (bus_rescan_devices_helper(dev, NULL) == 0)
+               err = count;
+       put_device(dev);
+       return err;
 }
 #endif
 
 }
 #endif