diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-15 10:47:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-15 10:47:28 -0500 |
commit | ab7cd8c76cb47f1bda0ad964d309b4efce81b5e9 (patch) | |
tree | b9fb10c6af24b475164a75c9ec8f411f933e467d /drivers/usb | |
parent | 3ea6b3d0e6d0ffd91c0f8cadeb69b7133c038b32 (diff) |
Revert "USB: Close usb_find_interface race"
This reverts commit a2582bd478c13c574d4c16ef1209d333f2a25935.
It turned out to be buggy and broke USB printers from working.
Cc: Russ Dill <Russ.Dill@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/usb.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 4e2c6df8d3cc..932f68e6ad19 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -167,17 +167,24 @@ struct usb_host_interface *usb_altnum_to_altsetting( | |||
167 | } | 167 | } |
168 | EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); | 168 | EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting); |
169 | 169 | ||
170 | struct find_interface_arg { | ||
171 | int minor; | ||
172 | struct usb_interface *interface; | ||
173 | }; | ||
174 | |||
170 | static int __find_interface(struct device *dev, void *data) | 175 | static int __find_interface(struct device *dev, void *data) |
171 | { | 176 | { |
172 | int *minor = data; | 177 | struct find_interface_arg *arg = data; |
173 | struct usb_interface *intf; | 178 | struct usb_interface *intf; |
174 | 179 | ||
175 | if (!is_usb_interface(dev)) | 180 | if (!is_usb_interface(dev)) |
176 | return 0; | 181 | return 0; |
177 | 182 | ||
178 | intf = to_usb_interface(dev); | 183 | intf = to_usb_interface(dev); |
179 | if (intf->minor != -1 && intf->minor == *minor) | 184 | if (intf->minor != -1 && intf->minor == arg->minor) { |
185 | arg->interface = intf; | ||
180 | return 1; | 186 | return 1; |
187 | } | ||
181 | return 0; | 188 | return 0; |
182 | } | 189 | } |
183 | 190 | ||
@@ -186,20 +193,21 @@ static int __find_interface(struct device *dev, void *data) | |||
186 | * @drv: the driver whose current configuration is considered | 193 | * @drv: the driver whose current configuration is considered |
187 | * @minor: the minor number of the desired device | 194 | * @minor: the minor number of the desired device |
188 | * | 195 | * |
189 | * This walks the bus device list and returns a pointer to the interface | 196 | * This walks the driver device list and returns a pointer to the interface |
190 | * with the matching minor. Note, this only works for devices that share the | 197 | * with the matching minor. Note, this only works for devices that share the |
191 | * USB major number. | 198 | * USB major number. |
192 | */ | 199 | */ |
193 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) | 200 | struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) |
194 | { | 201 | { |
195 | struct device *dev; | 202 | struct find_interface_arg argb; |
196 | 203 | int retval; | |
197 | dev = bus_find_device(&usb_bus_type, NULL, &minor, __find_interface); | ||
198 | |||
199 | /* Drop reference count from bus_find_device */ | ||
200 | put_device(dev); | ||
201 | 204 | ||
202 | return dev ? to_usb_interface(dev) : NULL; | 205 | argb.minor = minor; |
206 | argb.interface = NULL; | ||
207 | /* eat the error, it will be in argb.interface */ | ||
208 | retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb, | ||
209 | __find_interface); | ||
210 | return argb.interface; | ||
203 | } | 211 | } |
204 | EXPORT_SYMBOL_GPL(usb_find_interface); | 212 | EXPORT_SYMBOL_GPL(usb_find_interface); |
205 | 213 | ||