All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: rkagan@mail.ru
Subject: [PATCH] drivers/base/bus.c: fix iteration in driver_detach()
Date: Wed, 4 May 2005 23:57:01 -0700	[thread overview]
Message-ID: <11152762211382@kroah.com> (raw)
In-Reply-To: <11152762214193@kroah.com>

[PATCH] drivers/base/bus.c: fix iteration in driver_detach()

With 2.6.11 and 2.6.12-rc2 (and perhaps a few versions before) usb
drivers for multi-interface devices, which do
usb_driver_release_interface() in their disconnect(), make rmmod hang.

It turns out to be due to a bug in drivers/base/bus.c:driver_detach(),
that iterates over the list of attached devices with
list_for_each_safe() under an assumption that device_release_driver()
only releases the current device, while it may also call
device_release_driver() for other devices on the same list.

The following patch fixes it.  Please consider applying.

Signed-off-by: Roman Kagan <rkagan@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit b2d84f078a8be40f5ae3b4d2ac001e2a7f45fe4f
tree 173f941991f1b68da820e9926a3b7ebdd3a2c8b9
parent 177a4324944478f2799ce4ede2797cb0f602f274
author Roman Kagan <rkagan@mail.ru> 1113414017 +0400
committer Greg KH <gregkh@suse.de> 1115275478 -0700

Index: drivers/base/bus.c
===================================================================
--- cc42dcdbce1c3b53ea147abd3ebf784f0d2bf1bc/drivers/base/bus.c  (mode:100644 sha1:f4fa27315fb4b69841ecf2a551d58d9a241c5546)
+++ 173f941991f1b68da820e9926a3b7ebdd3a2c8b9/drivers/base/bus.c  (mode:100644 sha1:2b3902c867dab76cf5b9b9d65d1778be20ac20e1)
@@ -405,9 +405,8 @@
 
 static void driver_detach(struct device_driver * drv)
 {
-	struct list_head * entry, * next;
-	list_for_each_safe(entry, next, &drv->devices) {
-		struct device * dev = container_of(entry, struct device, driver_list);
+	while (!list_empty(&drv->devices)) {
+		struct device * dev = container_of(drv->devices.next, struct device, driver_list);
 		device_release_driver(dev);
 	}
 }


      reply	other threads:[~2005-05-05  6:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-05  6:56 [GIT PATCH] driver core bugfixes for 2.6.12-rc3 Greg KH
2005-05-05  6:57 ` [PATCH] Hotplug: Make dev->bus checking consistent Greg KH
2005-05-05  6:57   ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11152762211382@kroah.com \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rkagan@mail.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.