Subject: [PATCH] Fix manual binding infinite loop

From: Greg Kroah-Hartman <[email-masked]>
Date: Wed, 17 Aug 2005 17:33:11 -0700

Fix for manual binding of drivers to devices.  Problem is if you pass in
a valid device id, but the driver refuses to bind.  Infinite loop as
write() tries to resubmit the data it just sent.

Thanks to Michal Ostrowski <[email-masked]> for pointing the
problem out.

Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 drivers/base/bus.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- gregkh-2.6.orig/drivers/base/bus.c	2005-08-30 12:18:10.000000000 -0700
+++ gregkh-2.6/drivers/base/bus.c	2005-08-30 12:18:13.000000000 -0700
@@ -156,7 +156,9 @@ static ssize_t driver_unbind(struct devi
 		device_release_driver(dev);
 		err = count;
 	}
-	return err;
+	if (err)
+		return err;
+	return count;
 }
 static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);