Hi,

usblcd registers a device before all buffers are allocated leading
to a race resulting in NULL pointers being followed.
This fixes it.

        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-16 12:57:46+02:00, [EMAIL PROTECTED]
  - register device only after all buffers are allocated


 usblcd.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)


diff -Nru a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
--- a/drivers/usb/misc/usblcd.c Wed Jul 16 13:00:04 2003
+++ b/drivers/usb/misc/usblcd.c Wed Jul 16 13:00:04 2003
@@ -1,4 +1,4 @@
-/***************************************************************************** 
+/*****************************************************************************
  *                          USBLCD Kernel Driver                             *
  *        See http://www.usblcd.de for Hardware and Documentation.           *
  *                            Version 1.03                                   *
@@ -18,7 +18,7 @@
 #include <asm/uaccess.h>
 #include <linux/usb.h>
 
-#define DRIVER_VERSION "USBLCD Driver Version 1.03"
+#define DRIVER_VERSION "USBLCD Driver Version 1.04"
 
 #define USBLCD_MINOR           144
 
@@ -257,7 +257,7 @@
        struct lcd_usb_data *lcd = &lcd_instance;
        int i;
        int retval;
-       
+
        if (dev->descriptor.idProduct != 0x0001  ) {
                warn(KERN_INFO "USBLCD model not supported.");
                return -ENODEV;
@@ -274,29 +274,31 @@
                (i & 0xF000)>>12,(i & 0xF00)>>8,(i & 0xF0)>>4,(i & 0xF),
                dev->devnum);
 
-       retval = usb_register_dev(intf, &usb_lcd_class);
-       if (retval) {
-               err("Not able to get a minor for this device.");
-               return -ENOMEM;
-       }
+
 
        lcd->present = 1;
        lcd->lcd_dev = dev;
 
        if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
                err("probe_lcd: Not enough memory for the output buffer");
-               usb_deregister_dev(intf, &usb_lcd_class);
                return -ENOMEM;
        }
        dbg("probe_lcd: obuf address:%p", lcd->obuf);
 
        if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
                err("probe_lcd: Not enough memory for the input buffer");
-               usb_deregister_dev(intf, &usb_lcd_class);
                kfree(lcd->obuf);
                return -ENOMEM;
        }
        dbg("probe_lcd: ibuf address:%p", lcd->ibuf);
+
+       retval = usb_register_dev(intf, &usb_lcd_class);
+       if (retval) {
+               err("Not able to get a minor for this device.");
+               kfree(lcd->obuf);
+               kfree(lcd->ibuf);
+               return -ENOMEM;
+       }
 
        usb_set_intfdata (intf, lcd);
        return 0;

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


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


begin 664 bkpatch26801
M'XL(`#0P%3\``\U46V^;,!1^QK_B*)6F=!W!-F"<3*FZE6BKUIO2M4^3(@(F
M02&X,M"J&OOO.Y!>M$NK=>O#++"/S_'Y?"Z?O`7GI3(C2^?9E3)D"S[JLAI9
M**_K1!6#0M6K>CW09H&VJ=9H<[EMAIL PROTECTED]/9*%4ZE]<Q%P1/G$95O`0TE".+
M#=Q[375SJ4;6=/+A_/#=E)#Q&/:74;%09ZJ"\9C,5WM)K?+!RNAHV5[6W)L;
M3BECC/O4]07S&RY=UVN8H/,$Q80'PW0NAF03SMYOXOX1RJ4!^DI/^F[#N92"
MA,`&G+DN4->A@<,$,[EMAIL PROTECTED]@?40J/0\,.`YN2]_#O\>^3&&PP:I&5E3*0
MJ*LL5J"+_`:BM-5$>0[S.DVQM!`9U>YU'%4J(9^`>RQPR>E#38G]S$$(C2C9
MA05&L+?)(M;K)C%MZJ53EW-GG95Q*^1Q,HC;K#B5/&A7+AOJ#85L1)RD4<"#
M1`K&YFG\1.F>[EMAIL PROTECTED]>+QQN7"]CC*/NK04>MG(GP7G4L$I"[#'LG$#7]".
M4TS^PBC^)XSB8+/[EMAIL PROTECTED];LI^`;:Z[#SER^G@'_H)P(0-&#MK)>[EMAIL PROTECTED]
MK42E6:[EMAIL PROTECTED]<3*8S_,[EMAIL PROTECTED]@
M/@C`Q[UDMWLI40CYT.^.#8<@46T955U%.8P!BS*[J_H,J][/BBI]`Z]:/59K
M%N=166Z_)5:60G_CM0U?B64I8_J]8UU!-,\55!H6^#Q&L,X*;2#%OUIFY6T?
M![T6P5JE^`#W$=7>U=C*GW79G0ZOJ4T!]N3XY&ARA)IO#\]UO%3QJJS78YY2
-$3$JR'?"KG>[EMAIL PROTECTED]
`
end



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to