Skip to contentSkip to conversation

usb-serial : fix the nousb oops

PATCH In review Dave Young 3 participants 10 messages Feb 1, 2009 – Feb 6, 2009

Subsystems (2)
lore
Share & tools
lore

Dave Young

author
#0 lore raw

PATCH 1/2 usb-serial : fix the nousb oops

In case with "nousb" booting, serial drivers will trigger kernel oops.

Here add usb_disabled() check in usb_serial_init and usb_serial_register

---
drivers/usb/serial/usb-serial.c | 6 ++++++

1 file changed, 6 insertions(+)
drivers/usb/serial/usb-serial.c +6 -0
diff -uprN a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
@@ -1113,6 +1113,9 @@ static int __init usb_serial_init(void)
 	int i;
 	int result;
 
+	if (usb_disabled())
+		return -ENODEV;
+
 	usb_serial_tty_driver = alloc_tty_driver(SERIAL_TTY_MINORS);
 	if (!usb_serial_tty_driver)
 		return -ENOMEM;
@@ -1230,6 +1233,9 @@ int usb_serial_register(struct usb_seria
 	/* must be called with BKL held */
 	int retval;
 
+	if (usb_disabled())
+		return -ENODEV;
+
 	fixup_generic(driver);
 
 	if (!driver->description)
#1 lore raw
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Quoted 1 line

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

confused,

greg k-h

author
#2 lore raw
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 5 lines
Quoted 2 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

Quoted 5 lines

confused,

greg k-h

Signature · 2 lines
Regards
dave
author
#3 lore raw
Quoted 9 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

I can not copy the oops message, so I just hand copy something here:

BUG: unable to handle kernel NULL pointer dereference at 00000001
IP: [<c0527636>] kset_find_obj+0x3b/0x5c
*pde = 00000000
Oops: 0000 [#1] SMP

[snip...]

EIP is at kset_find_obj+0x3b/0x5c
EAX:00000001

[snip...]

Call Trace:

driver_register
destruct_tty_driver
usb_serial_bus_register
usb_serial_register
aircable_init
_stext
aircable_init
restore_nocheck_notrace
pci_arch_init

[snip...]

Actually, after the usb_serial_init failed, the usb_serial_bus_type will be unregistered.

So when serial dirvers call usb_serial_register (then usb_serial_bus_register, and then driver_register), due to the bus kset already unregistered kernel will oops.

Quoted 23 lines
Quoted 6 lines
Quoted 3 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

Quoted 5 lines

confused,

greg k-h

--
Regards
dave

Signature · 2 lines
Regards
dave
#4 lore raw
In reply to Dave Young
Quoted 11 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

And this should only be an issue if you build your drivers into the kernel, right?

thanks,

greg k-h

author
#5 lore raw

remove [email protected] in cc-list because this mail will be rejected by the smva.com email server.

Quoted 17 lines · Greg KH
Quoted 16 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 5 lines
Quoted 2 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

Quoted 7 lines
Quoted 3 lines

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

Hi greg

I think all usb serial drivers which call usb_serial_register will oops, so IMHO usb core should be fixed.

I think maybe you missed my another reply, copy the content here again.

---
hand copy part of the oops message:

BUG: unable to handle kernel NULL pointer dereference at 00000001
IP: [<c0527636>] kset_find_obj+0x3b/0x5c
*pde = 00000000
Oops: 0000 [#1] SMP

[snip...]

EIP is at kset_find_obj+0x3b/0x5c
EAX:00000001

[snip...]

Call Trace:

driver_register
destruct_tty_driver
usb_serial_bus_register
usb_serial_register
aircable_init
_stext
aircable_init
restore_nocheck_notrace
pci_arch_init

[snip...]

Actually, after the usb_serial_init failed, the usb_serial_bus_type will be unregistered.

So when serial dirvers call usb_serial_register (then usb_serial_bus_register, and then driver_register), due to the bus kset already unregistered kernel will oops.
---

Quoted 3 lines

And this should only be an issue if you build your drivers into the kernel, right?

Yes.

Quoted 5 lines

thanks,

greg k-h

Signature · 2 lines
Regards
dave
#9 lore raw
In reply to Greg KH

Am Wednesday 04 February 2009 00:58:14 schrieb Greg KH:

Quoted 9 lines · Dave Young
Quoted 4 lines

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

usb_register() can also fail for other reasons. There's no way you can save drivers from needing to cleanly fail in that case.

Quoted 2 lines

And this should only be an issue if you build your drivers into the kernel, right?

No, you can load drivers by other methods than udev.

Regards
Oliver

#6 lore raw
In reply to Dave Young
Quoted 29 lines · Dave Young

remove [email protected] in cc-list because this mail will be rejected by the smva.com email server.

Quoted 17 lines · Greg KH
Quoted 16 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 5 lines
Quoted 2 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

Quoted 7 lines
Quoted 3 lines

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

Quoted 6 lines

Hi greg

I think all usb serial drivers which call usb_serial_register will oops, so IMHO usb core should be fixed.

I think maybe you missed my another reply, copy the content here again.

No, I got it.

I'm more interested in why usb-serial is oopsing, as it should't be.

Quoted 2 lines

---
hand copy part of the oops message:

Can you take a picture of the oops?

thanks,

greg k-h

author
#7 lore raw
Quoted 37 lines · Greg KH
Quoted 29 lines · Dave Young

remove [email protected] in cc-list because this mail will be rejected by the smva.com email server.

Quoted 17 lines · Greg KH
Quoted 16 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 5 lines
Quoted 2 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

Quoted 7 lines
Quoted 3 lines

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

Quoted 6 lines

Hi greg

I think all usb serial drivers which call usb_serial_register will oops, so IMHO usb core should be fixed.

I think maybe you missed my another reply, copy the content here again.

Quoted 8 lines

No, I got it.

I'm more interested in why usb-serial is oopsing, as it should't be.

Quoted 2 lines

---
hand copy part of the oops message:

Can you take a picture of the oops?

Hi, I have no camera at hand, I will take the picture tomorrow.

Quoted 5 lines

thanks,

greg k-h

Signature · 2 lines
Regards
dave
author
#8 lore raw
In reply to Greg KH
Quoted 37 lines · Greg KH
Quoted 29 lines · Dave Young

remove [email protected] in cc-list because this mail will be rejected by the smva.com email server.

Quoted 17 lines · Greg KH
Quoted 16 lines · Dave Young
Quoted 5 lines · Greg KH
Quoted 2 lines · Dave Young

In case with "nousb" booting, serial drivers will trigger kernel oops.

They will? What is the oops message?

Yes, they will, at lease I saw usb_serial/aircable/ftdi_sio oops. I will manage to copy the oops message later.

Quoted 5 lines
Quoted 2 lines

Here add usb_disabled() check in usb_serial_init and usb_serial_register

This is odd, is it something new? Why is usb-serial the only driver that needs such a thing?

Quoted 7 lines
Quoted 3 lines

No, it is not new thing. usb serial drivers normally call usb_serial_register first, then usb_register, usb_register will fail due to "nousb" checking, but usb_serial_register no.

But as usb_register will fail, shouldn't they properly back out and no oopses happen? This sounds like a simple fix to the drivers that are failing here, not changing the usb-serial core.

Quoted 6 lines

Hi greg

I think all usb serial drivers which call usb_serial_register will oops, so IMHO usb core should be fixed.

I think maybe you missed my another reply, copy the content here again.

Quoted 8 lines

No, I got it.

I'm more interested in why usb-serial is oopsing, as it should't be.

Quoted 2 lines

---
hand copy part of the oops message:

Can you take a picture of the oops?

Hi, greg:

Yestoday I found that with two diffrent config there's diffrent EIP, please see the attachment (configs), you can use the configs to create the panic.

Due to the image files size I only send them to you in another email.

Quoted 5 lines

thanks,

greg k-h

Signature · 2 lines
Regards
dave