Hi,

registering the device before setting the interface data can lead
to a null pointer being followed in open(). This patch fixes that.

        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-07-15 17:33:44+02:00, [EMAIL PROTECTED]
  - fix race between probe and open


 usblp.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)


diff -Nru a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
--- a/drivers/usb/class/usblp.c Tue Jul 15 17:35:45 2003
+++ b/drivers/usb/class/usblp.c Tue Jul 15 17:35:45 2003
@@ -831,22 +831,15 @@
        init_waitqueue_head(&usblp->wait);
        usblp->ifnum = intf->altsetting->desc.bInterfaceNumber;
 
-       retval = usb_register_dev(intf, &usblp_class);
-       if (retval) {
-               err("Not able to get a minor for this device.");
-               goto abort;
-       }
-       usblp->minor = intf->minor;
-
        usblp->writeurb = usb_alloc_urb(0, GFP_KERNEL);
        if (!usblp->writeurb) {
                err("out of memory");
-               goto abort_minor;
+               goto abort;
        }
        usblp->readurb = usb_alloc_urb(0, GFP_KERNEL);
        if (!usblp->readurb) {
                err("out of memory");
-               goto abort_minor;
+               goto abort;
        }
 
        /* Malloc device ID string buffer to the largest expected length,
@@ -854,7 +847,7 @@
         * could change in length. */
        if (!(usblp->device_id_string = kmalloc(USBLP_DEVICE_ID_SIZE, GFP_KERNEL))) {
                err("out of memory for device_id_string");
-               goto abort_minor;
+               goto abort;
        }
 
        usblp->writebuf = usblp->readbuf = NULL;
@@ -866,19 +859,19 @@
        if (!(usblp->writebuf = usb_buffer_alloc(dev, USBLP_BUF_SIZE,
                                GFP_KERNEL, &usblp->writeurb->transfer_dma))) {
                err("out of memory for write buf");
-               goto abort_minor;
+               goto abort;
        }
        if (!(usblp->readbuf = usb_buffer_alloc(dev, USBLP_BUF_SIZE,
                                GFP_KERNEL, &usblp->readurb->transfer_dma))) {
                err("out of memory for read buf");
-               goto abort_minor;
+               goto abort;
        }
 
        /* Allocate buffer for printer status */
        usblp->statusbuf = kmalloc(STATUS_BUF_SIZE, GFP_KERNEL);
        if (!usblp->statusbuf) {
                err("out of memory for statusbuf");
-               goto abort_minor;
+               goto abort;
        }
 
        /* Lookup quirks for this printer. */
@@ -892,12 +885,12 @@
                dbg("incompatible printer-class device 0x%4.4X/0x%4.4X",
                        dev->descriptor.idVendor,
                        dev->descriptor.idProduct);
-               goto abort_minor;
+               goto abort;
        }
 
        /* Setup the selected alternate setting and endpoints. */
        if (usblp_set_protocol(usblp, protocol) < 0)
-               goto abort_minor;
+               goto abort;
 
        /* Retrieve and store the device ID string. */
        usblp_cache_device_id_string(usblp);
@@ -916,10 +909,17 @@
 
        usb_set_intfdata (intf, usblp);
 
+       retval = usb_register_dev(intf, &usblp_class);
+       if (retval) {
+               err("Not able to get a minor for this device.");
+               goto abort_intfdata;
+       }
+       usblp->minor = intf->minor;
+
        return 0;
 
-abort_minor:
-       usb_deregister_dev(intf, &usblp_class);
+abort_intfdata:
+       usb_set_intfdata (intf, NULL);
 abort:
        if (usblp) {
                if (usblp->writebuf)

===================================================================


This BitKeeper patch contains the following changesets:
1.2083
## Wrapped with gzip_uu ##


begin 664 bkpatch21899
M'XL(`%$?%#\``[U4:T_;,!3]'/^**Y`F$&[EMAIL PROTECTED];WR953N*T
M4=NX<E+8M.R_[]9!L'9E+Z1%B:[CDW,?QT?9A9M&F=31L^I6&;(+;[EMAIL PROTECTED]
MY\M"U6ZMEM/EW-5FC-BUUHAY$SU77D_P/AJE&F^V6#89P2^N9)M/`($F=9CK
M/^RT7Q8J=:[/WMQ<O+HF9#B$DXFLQ^J#:F$X)-GTN%BJF3LU6DY6Q;H'N..4
M,L9X2/TP8F''8]\/.A;1K,!EP4529E%"QD:-CWMZKN?K=)[EMAIL PROTECTED],
M?'(*S.4T]H'Z'A4>"X&)U/?3(#B@/[EMAIL PROTECTED]&E+R&Y_=\0G(80%E]
M!B-S!9EJ[Y2J86%TID#6!>B%JLD["*,XYN3J43(R^,N+$"HI.=K2<[EMAIL PROTECTED]>
MGI^W,%7=*N/FC_T'-&%1Y_.`)UU62AHG?B("65(_+W\ATEK:?"8;NYHM^M1X
M'BQD(6K".YK0.+"&>)*RW2#/:'S3++]I-N*4"<PI.A;0.+;F$>PGZ_`_L8Z`
M`1/_U3Q6W_<P,'?V1B]</2WU/QCK-/8#$!B"[EMAIL PROTECTED]/CC'6K06;:M(<K+.FQ
M9`L6"HO9L(E%/2_:QA-]/;&M7LPL9L,FEH06LV$#2_#X$.O#.G:>L!C'=(QJ
M;^4,AH"*C=!&58/&&[EMAIL PROTECTED];)D55U_Y`X50E[/6<?OF).9<S>SJ5N
M,>],`>8?XQ]0PKRJM8$2GW92-8#YJERY.ZL,/[0Q6M4H9"MQ^QMQ;*G!4<\=
[EMAIL PROTECTED]:SH!CXYQC6.>GECQJU.,6W`]P>[EMAIL PROTECTED]'
-L@@[EMAIL PROTECTED]"9B,P8`````
`
end



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to