Hi,
this function races with itself, doesn't return errors and races with
releasing interfaces. This patch fixes it by changing the function
prototype, introducing locking and having a correct order in
releasing interfaces.
Regards
Oliver
You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
===================================================================
[EMAIL PROTECTED], 2003-08-11 21:39:31+02:00, [EMAIL PROTECTED]
- API change to check errors in usb_driver_claim_interface and
fix a race condition between releasing and reclaiming an interface
drivers/usb/core/usb.c | 27 +++++++++++++++------------
include/linux/usb.h | 2 +-
2 files changed, 16 insertions(+), 13 deletions(-)
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c Mon Aug 11 21:40:47 2003
+++ b/drivers/usb/core/usb.c Mon Aug 11 21:40:47 2003
@@ -261,24 +261,27 @@
*
* Few drivers should need to use this routine, since the most natural
* way to bind to an interface is to return the private data from
- * the driver's probe() method. Any driver that does use this must
- * first be sure that no other driver has claimed the interface, by
- * checking with usb_interface_claimed().
+ * the driver's probe() method.
*/
-void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface
*iface, void* priv)
+int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface
*iface, void* priv)
{
if (!iface || !driver)
- return;
+ return -EINVAL;
- // FIXME change API to report an error in this case
- if (iface->driver)
- err ("%s driver booted %s off interface %p",
- driver->name, iface->driver->name, iface);
- else
+ lock_kernel();
+ if (iface->driver) {
+ unlock_kernel();
+ err ("%s driver booted %s off interface %p",
+ driver->name, iface->driver->name, iface);
+ return -EBUSY;
+ } else {
dbg("%s driver claimed interface %p", driver->name, iface);
+ }
iface->driver = driver;
usb_set_intfdata(iface, priv);
+ unlock_kernel();
+ return 0;
}
/**
@@ -324,11 +327,11 @@
if (iface->driver && iface->driver != driver)
return;
- iface->driver = NULL;
- usb_set_intfdata(iface, NULL);
usb_set_interface(interface_to_usbdev(iface),
iface->altsetting[0].desc.bInterfaceNumber,
0);
+ usb_set_intfdata(iface, NULL);
+ iface->driver = NULL;
}
/**
diff -Nru a/include/linux/usb.h b/include/linux/usb.h
--- a/include/linux/usb.h Mon Aug 11 21:40:47 2003
+++ b/include/linux/usb.h Mon Aug 11 21:40:47 2003
@@ -290,7 +290,7 @@
extern int usb_get_current_frame_number (struct usb_device *usb_dev);
/* used these for multi-interface device registration */
-extern void usb_driver_claim_interface(struct usb_driver *driver,
+extern int usb_driver_claim_interface(struct usb_driver *driver,
struct usb_interface *iface, void* priv);
extern int usb_interface_claimed(struct usb_interface *iface);
extern void usb_driver_release_interface(struct usb_driver *driver,
===================================================================
This BitKeeper patch contains the following changesets:
1.2214
## Wrapped with gzip_uu ##
begin 664 bkpatch24707
M'XL(`$#Q-S\``ZU6;6_:2!#^[/T5HU;[EMAIL PROTECTED];:,[U*B-TDNE^Q3Y
M90T6MC=:VVFBH__]QFL$A#JH1XN0=IF=EV=FYYGE-=R64H\ME:4/4I/7\)<J
MJ[&%^[R.93$H9+VH\X'2,SR[40K/AG.5RV%K,/Q;[EMAIL PROTECTED]>[EMAIL PROTECTED]:`
M)[EMAIL PROTECTED]/]W)LW5S^>7MU<4/(9`+OYT$QDU]D!9,)"1?G<2VSP4*K8-Y$
M6ZZ/EYQ2QAAWJ'!<YBSY2`A[R5P:QKB-N><GH>N3F9:S\]8\4OES<T%'U.&<
M>]1;VJ[/*?D`;,`YLX&*(1T-&0/.QL(?"_:6\C&ET*9WWE$'>,NA3\D[^'7,
M[TD$?;BXGD)D+*%2N)/1`J362I>0%H!UO8MU`^8NRH(TOTN+2NHDB"0$18P.
M`)[EMAIL PROTECTED],I-!F1:S1AU_&2?M3UB[(A_!]FW?)]>;
M:R']__DAA`:4G'74)2VB#*LXS-*B?AQB1H/YID(V=6RZI*YM>\N8<Q&/8L=)
M7%NX;,\MO.03KQK=^L+G+E8=Z]\)J"[EMAIL PROTECTED]@;CL_05-B.O8Q<+J4SXLR+
MPD!09Q^>;9>[EMAIL PROTECTED]'N<F(O1&[EMAIL PROTECTED]@
[EMAIL PROTECTED],B0/%G(/$7I'V-=5K8L5;8Q-0PI#B72;`VN;$L(G4"'.OH=&
M7LT;[FBD1P5*QS@)/T)[5Y^AK[^9+W;[EMAIL PROTECTED]/G#7!D&FW'[EMAIL PROTECTED]
M?Y1PKU78Y)7+:J[B0:,[EMAIL PROTECTED]/8.MH,T>[EMAIL PROTECTED]>5
MQL<8.GTXPH`>,P'-8EFK`O<OIY^^7ER=-N<"G.;<`X]8F8H6=PNI"YGUCDZ)
ME2;0,U[[9VWH([EMAIL PROTECTED]:]5V_*5>X0XALC8T"!2I+-?<&;^U<GJ&ZU
M:OVS([EMAIL PROTECTED],8SX3&[EMAIL PROTECTED]@%<3>%M+[C;[EMAIL PROTECTED])BNX
MASI3(5I5K%XIJZ:"[EMAIL PROTECTED]&+DIX;T'4.KF_&'3LQ=RK\\
M)5N^,X[,<ZEK^,Z<'][#G^,[TOTWLGWU%B(%*M7\;<!&V-/M2-1VSN\0M2/S
[EMAIL PROTECTED]"T,#L\A'#&J>S</HM_F#9%[YLLXG"8W=R.8A^0_@;P2]B0D`````
`
end
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel