Fix usb_find_interface. You cannot case pointers to int and long on
a big-endian 64-bitter without consequences.
Signed-off-by: Pete Zaitcev <[EMAIL PROTECTED]>
---
Whenever you see code like this, it's a huge red flag:
struct usb_interface ** ret = (struct usb_interface **)data;
struct usb_interface * intf = *ret;
int *minor = (int *)data;
It's terribly ugly. But it also is wrong, because someone cast major to
long in the caller (to suppress a gcc warning, no doubt). Thus, *minor
accesses the MSW of the long.
Replacing the cast with long would work too, but this was just too much
to ignore.
It defies belief that someone would try to save one word on the stack
in this manner.
Fedora Bug 176333
--- linux-2.6.15-rc5-git6-gregkh/drivers/usb/core/usb.c 2005-12-17
02:02:07.000000000 -0800
+++ linux-2.6.15-rc5-git6-gregkh-ufind/drivers/usb/core/usb.c 2005-12-21
17:11:03.000000000 -0800
@@ -193,20 +193,23 @@ void usb_driver_release_interface(struct
iface->condition = USB_INTERFACE_UNBOUND;
mark_quiesced(iface);
}
+struct find_interface_arg {
+ int minor;
+ struct usb_interface *interface;
+};
static int __find_interface(struct device * dev, void * data)
{
- struct usb_interface ** ret = (struct usb_interface **)data;
- struct usb_interface * intf = *ret;
- int *minor = (int *)data;
+ struct find_interface_arg *arg = data;
+ struct usb_interface *intf;
/* can't look at usb devices, only interfaces */
if (dev->driver == &usb_generic_driver)
return 0;
intf = to_usb_interface(dev);
- if (intf->minor != -1 && intf->minor == *minor) {
- *ret = intf;
+ if (intf->minor != -1 && intf->minor == arg->minor) {
+ arg->interface = intf;
return 1;
}
return 0;
@@ -223,12 +226,12 @@ static int __find_interface(struct devic
*/
struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
{
- struct usb_interface *intf = (struct usb_interface *)(long)minor;
- int ret;
-
- ret = driver_for_each_device(&drv->driver, NULL, &intf,
__find_interface);
+ struct find_interface_arg argb;
- return ret ? intf : NULL;
+ argb.minor = minor;
+ argb.interface = NULL;
+ driver_for_each_device(&drv->driver, NULL, &argb, __find_interface);
+ return argb.interface;
}
#ifdef CONFIG_HOTPLUG
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel