From gregkh@suse.de Wed Aug 17 17:33:11 2005
Date: Wed, 17 Aug 2005 17:33:11 -0700
From: Greg Kroah-Hartman <gregkh@suse.de>
To: torvalds@osdl.org, Andrew Morton <akpm@osdl.org>
Cc: Michal Ostrowski <mostrows@watson.ibm.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] Fix manual binding infinite loop

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 <mostrows@watson.ibm.com> for pointing the
problem out.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 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);