ChangeSet 1.1726, 2004/05/17 11:00:46-07:00, zwane@fsmlabs.com [PATCH] USB: fix usb-serial serial_open oops No usb serial devices, just compiled in and the system has a USB controller. Unable to handle kernel NULL pointer dereference at virtual address 0000000c printing eip: c046a188 *pde = 00000000 Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC Modules linked in: CPU: 0 EIP: 0060:[] Not tainted VLI EFLAGS: 00010246 (2.6.6-mm3) EIP is at serial_open+0x38/0x170 eax: 00000000 ebx: dc883000 ecx: c0613db8 edx: 00000000 esi: 00000001 edi: 00000000 ebp: dc84cef0 esp: dc84cedc ds: 007b es: 007b ss: 0068 Process serial (pid: 1073, threadinfo=dc84c000 task=ddffca50) Stack: 00000000 de8f4f5c ffffffed 00000100 de8f4f5c dc84cf14 c035a874 090115a0 0bc00000 dc883000 00000000 de8f4f5c 00000001 df8a2dfc dc84cf40 c0171270 dc84c000 00000001 00000000 de8f4f5c dbc75e94 00000000 de8f4f5c dbc75e94 Call Trace: [] show_stack+0x75/0x90 [] show_registers+0x11f/0x180 [] die+0xb6/0x170 [] do_page_fault+0x1e0/0x525 [] error_code+0x2d/0x40 [] tty_open+0x274/0x3b0 [] chrdev_open+0x160/0x340 [] dentry_open+0x156/0x230 [] filp_open+0x4d/0x50 [] sys_open+0x38/0x70 [] sysenter_past_esp+0x52/0x79 Code: de 63 c0 89 55 f0 c7 45 ec 00 00 00 00 85 f6 0f 85 31 01 00 00 c7 83 8c 09 00 00 00 00 00 00 8b 43 08 e8 3c fe ff ff 31 d2 89 c7 <8a> 50 0c 8b 43 08 29 d0 8b 74 87 18 89 b3 8c 09 00 00 89 5e 04 (gdb) list *serial_open+0x38 0xc046a188 is in serial_open (drivers/usb/serial/usb-serial.c:465). 460 461 /* get the serial object associated with this tty pointer */ 462 serial = usb_serial_get_by_index(tty->index); 463 464 /* set up our port structure making the tty driver remember our port object, and us it */ 465 portNumber = tty->index - serial->minor; 466 port = serial->port[portNumber]; 467 tty->driver_data = port; 468 469 port->tty = tty; drivers/usb/serial/usb-serial.c | 7 +++++++ 1 files changed, 7 insertions(+) diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c --- a/drivers/usb/serial/usb-serial.c Mon May 17 16:38:05 2004 +++ b/drivers/usb/serial/usb-serial.c Mon May 17 16:38:05 2004 @@ -460,6 +460,10 @@ /* get the serial object associated with this tty pointer */ serial = usb_serial_get_by_index(tty->index); + if (!serial) { + retval = -ENODEV; + goto bailout; + } /* set up our port structure making the tty driver remember our port object, and us it */ portNumber = tty->index - serial->minor; @@ -493,6 +497,9 @@ static void serial_close(struct tty_struct *tty, struct file * filp) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + + if (!port) + return; dbg("%s - port %d", __FUNCTION__, port->number);