# Kernel Oops when remove USB flash drive (2.6.* love sources)

## tdb

I started getting oopses when I remove my PNY Attache 128m USB flash drive recently. It happens on all the 2.6 kernels I've tried so far. (I think it used to work on them, but now I'm not sure.) I also tried with preempt turned off. I tried updating hotplug to the latest version, it didn't work. I  have the same problem when I plug in my digital camera.  I googled a bit and tried a few different patches people had posted. None of them worked. Most of the people said the problem just went away after a day. Its been three days here. How do I let someone know that the issue is still open?

Here is the mess from my system logs:

Feb 1 15:35:45 ubertop hub 1-0:1.0: new USB device on port 4, assigned address

2

Feb 1 15:35:45 ubertop Initializing USB Mass Storage driver...

Feb 1 15:35:45 ubertop scsi0 : SCSI emulation for USB Mass Storage devices

Feb 1 15:35:45 ubertop Vendor: Model: USB DISK 2.0 Rev: 1.1b

Feb 1 15:35:45 ubertop Type: Direct-Access ANSI SCSI rev

ision: 02

Feb 1 15:35:45 ubertop scsi.agent[5081]: how to add device type= at /devices/pc

i0000:00/0000:00:0b.2/usb1/1-4/1-4:1.0/host0/0:0:0:0 ??

Feb 1 15:35:46 ubertop SCSI device sda: 253952 512-byte hdwr sectors (130 MB)

Feb 1 15:35:46 ubertop sda: assuming Write Enabled

Feb 1 15:35:46 ubertop sda: assuming drive cache: write through

Feb 1 15:35:46 ubertop /dev/scsi/host0/bus0/target0/lun0: p1

Feb 1 15:35:46 ubertop Attached scsi removable disk sda at scsi0, channel 0, id

0, lun 0

Feb 1 15:35:46 ubertop Attached scsi generic sg0 at scsi0, channel 0, id 0, lun

0, type 0

Feb 1 15:35:46 ubertop WARNING: USB Mass Storage data integrity not assured

Feb 1 15:35:46 ubertop USB Mass Storage device found at 2

Feb 1 15:35:46 ubertop drivers/usb/core/usb.c: registered new driver usb-storag

e

Feb 1 15:35:46 ubertop USB Mass Storage support registered.

Feb 1 15:35:50 ubertop usb 1-4: USB disconnect, address 2

Feb 1 15:35:50 ubertop releasing anticipatory io scheduler

Feb 1 15:35:50 ubertop Unable to handle kernel NULL pointer dereference at virt

ual address 00000001

Feb 1 15:35:50 ubertop printing eip:

Feb 1 15:35:50 ubertop 00000001

Feb 1 15:35:50 ubertop *pde = 00000000

Feb 1 15:35:50 ubertop Oops: 0000 [#1]

Feb 1 15:35:50 ubertop PREEMPT

Feb 1 15:35:50 ubertop CPU: 0

Feb 1 15:35:50 ubertop EIP: 0060:[<00000001>] Tainted: P VLI

Feb 1 15:35:50 ubertop EFLAGS: 00010202

Feb 1 15:35:50 ubertop EIP is at 0x1

Feb 1 15:35:50 ubertop eax: da063280 ebx: d379d000 ecx: 00000001 edx: d37

9d000

Feb 1 15:35:50 ubertop esi: d379d010 edi: 00000282 ebp: d379d8b0 esp: db6

f5e18

Feb 1 15:35:50 ubertop ds: 007b es: 007b ss: 0068

Feb 1 15:35:50 ubertop Process khubd (pid: 2578, threadinfo=db6f4000 task=db709

310)

Feb 1 15:35:50 ubertop Stack: c02a03d9 d379d000 da063280 c02a24c9 d379d000 d37b

5024 d37b5000 c02c6808

Feb 1 15:35:50 ubertop d379d000 00000000 c03e59f0 c03e5a20 d379d8d8 c029ce0c d3

7b517c c029d1c0

Feb 1 15:35:50 ubertop d37b51a4 00000042 d37b51a4 c0248f21 d37b51a4 d37b5000 db

6f4000 db6f4000

Feb 1 15:35:50 ubertop Call Trace:

Feb 1 15:35:50 ubertop [<c02a03d9>] elevator_exit+0x36/0x42

Feb 1 15:35:50 ubertop [<c02a24c9>] blk_cleanup_queue+0x78/0x86

Feb 1 15:35:50 ubertop [<c02c6808>] scsi_device_dev_release+0x12a/0x191

Feb 1 15:35:50 ubertop [<c029ce0c>] device_release+0x20/0x78

Feb 1 15:35:50 ubertop [<c029d1c0>] device_del+0x7f/0xa0

Feb 1 15:35:50 ubertop [<c0248f21>] kobject_cleanup+0x98/0x9a

Feb 1 15:35:50 ubertop [<c02c634e>] scsi_forget_host+0x4c/0x94

Feb 1 15:35:50 ubertop [<c02c0726>] scsi_remove_host+0x2b/0x5b

Feb 1 15:35:50 ubertop [<ddb15b1e>] storage_disconnect+0x38/0x48 [usb_storage]

Feb 1 15:35:50 ubertop [<dda100ef>] usb_unbind_interface+0x7b/0x7d [usbcore]

Feb 1 15:35:50 ubertop [<c029e096>] device_release_driver+0x64/0x66

Feb 1 15:35:50 ubertop [<c029e1f6>] bus_remove_device+0x73/0xb8

Feb 1 15:35:50 ubertop [<c029d1ad>] device_del+0x6c/0xa0

Feb 1 15:35:50 ubertop [<dda15d4d>] usb_disable_device+0x71/0xac [usbcore]

Feb 1 15:35:50 ubertop [<dda10b57>] usb_disconnect+0xc3/0x10e [usbcore]

Feb 1 15:35:50 ubertop [<dda12aa1>] hub_port_connect_change+0x330/0x335 [usbcor

e]

Feb 1 15:35:50 ubertop [<dda123aa>] hub_port_status+0x45/0xb0 [usbcore]

Feb 1 15:35:50 ubertop [<dda12ddf>] hub_events+0x339/0x39e [usbcore]

Feb 1 15:35:50 ubertop [<dda12e71>] hub_thread+0x2d/0xe3 [usbcore]

Feb 1 15:35:50 ubertop [<c034936a>] ret_from_fork+0x6/0x14

Feb 1 15:35:50 ubertop [<c011c24c>] default_wake_function+0x0/0x12

Feb 1 15:35:50 ubertop [<dda12e44>] hub_thread+0x0/0xe3 [usbcore]

Feb 1 15:35:50 ubertop [<c0109289>] kernel_thread_helper+0x5/0xb

Feb 1 15:35:50 ubertop

Feb 1 15:35:50 ubertop Code: Bad EIP value.

----------

## tdb

*Bump*

Anyone? I think this has to do with the mm patchset. I found some discussion out there, and a few bug reports. The problem is that none of the patches they offered work for me.

----------

## steel300

It's definitely something in mm. Are you unmounting it before you remove it?

----------

## tdb

 *steel300 wrote:*   

> It's definitely something in mm. Are you unmounting it before you remove it?

 

Nope. All I have to do is insert it, my syslogs show that everything loaded fine. (usb-storage, etc...) Then I just pull it out, and it bombs. Not mounted or anything. It originally started doing it somewhere back in 2.6.1 rcX loveX; with just the PNY drive. (my digital camera was fine. ) Since about 2.6.2rc1 it started doing it for both. 

I have found some discussion on it in the lkml and kernel bugzilla. This is a porblem that looks like it first appeared back around 2.5.60 or so. Unfortunately it doesn't look like may people are experiencing it, and the few that have all said it went away the next day. A lot of the changelogs, (particulary the mm ones for 2.6.1 and 2.6.2) all have patches that look like the address the issue. I have a bad feeling that the people who need to know about it think it's resolved. I have no idea what could be causing it, but it's doing it on my Presario 2570us (USB 2.0 and Firewire laptop) and my older usb 1.1 desktop. (Aopen 63pro motherboard and a Via 82cxxx controller, I think.)

I'll try to find some time to experiment with other kernels, but with the bar exam less then two weeks away, it's going to be awhile.

----------

## sklettke

You're not alone;  I'm experiencing this too.

[EDIT]  Just read your last post and this problem exists on all usb-storage devices for me.  My USB JumpDrive, my camera, and mp3 player.  Just as an experiment I unplugged my USB Logitech mouse and then plugged it back in.  It now doesn't work nor does dmesg indicate that it is being detected.  So it looks like it affects all USB not usb-storage.

```
hub 2-0:1.0: new USB device on port 1, assigned address 3

scsi0 : SCSI emulation for USB Mass Storage devices

  Vendor: MINOLTA   Model: DiMAGE G400       Rev: 1.00

  Type:   Direct-Access                      ANSI SCSI revision: 02

SCSI device sda: 499712 512-byte hdwr sectors (256 MB)

sda: assuming Write Enabled

sda: assuming drive cache: write through

 /dev/scsi/host0/bus0/target0/lun0: p1

Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0

Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0,  type 0

WARNING: USB Mass Storage data integrity not assured

USB Mass Storage device found at 3

request_module: failed /sbin/modprobe -- nls_cp437. error = 256

Unable to load NLS charset cp437

Unable to load NLS charset iso8859-1

Unable to load NLS charset iso8859-1

usb 2-1: USB disconnect, address 3

releasing cfq io scheduler

Unable to handle kernel NULL pointer dereference at virtual address 00000001

 printing eip:

00000001

*pde = 00000000

Oops: 0000 [#1]

PREEMPT

CPU:    0

EIP:    0060:[<00000001>]    Tainted: PF  VLI

EFLAGS: 00010202

EIP is at 0x1

eax: d6bd5d80   ebx: d043d000   ecx: 00000001   edx: d043d000

esi: d043d010   edi: 00000286   ebp: d1d81cb0   esp: dfdede24

ds: 007b   es: 007b   ss: 0068

Process khubd (pid: 5, threadinfo=dfdec000 task=dff70080)

Stack: c023f975 d043d000 d6bd5d80 c02419da d043d000 d29a8c24 d29a8c00 e1986bd8

       d043d000 00000000 c03c9910 c03c9940 d1d81cd8 c023c6a0 d29a8d7c d29a8d7c

       d1d81cb0 c023ca2e d29a8da4 c01fcbb9 d29a8da4 d29a8c00 dfdec000 dfdec000

Call Trace:

 [<c023f975>] elevator_exit+0x36/0x42

 [<c02419da>] blk_cleanup_queue+0x78/0x86

 [<e1986bd8>] scsi_device_dev_release+0x12a/0x191 [scsi_mod]

 [<c023c6a0>] device_release+0x20/0x78

 [<c023ca2e>] device_del+0x70/0x9b

 [<c01fcbb9>] kobject_cleanup+0x98/0x9a

 [<e1986720>] scsi_forget_host+0x4c/0x94 [scsi_mod]

 [<e1980fca>] scsi_remove_host+0x2b/0x5b [scsi_mod]

 [<e19b1a4f>] storage_disconnect+0x38/0x48 [usb_storage]

 [<c02794f3>] usb_unbind_interface+0x7b/0x7d

 [<c023d85a>] device_release_driver+0x64/0x66

 [<c023d97e>] bus_remove_device+0x55/0x96

 [<c023ca1b>] device_del+0x5d/0x9b

 [<c027f05d>] usb_disable_device+0x71/0xac

 [<c0279f10>] usb_disconnect+0x9b/0xe6

 [<c027be30>] hub_port_connect_change+0x31d/0x322

 [<c027b74c>] hub_port_status+0x45/0xb0

 [<c027c16e>] hub_events+0x339/0x39e

 [<c027c200>] hub_thread+0x2d/0xe3

 [<c033462e>] ret_from_fork+0x6/0x14

 [<c011bdbc>] default_wake_function+0x0/0x12

 [<c027c1d3>] hub_thread+0x0/0xe3

 [<c0109289>] kernel_thread_helper+0x5/0xb

Code:  Bad EIP value.

```

I am getting this error on my Toshiba 5105-S607.  I am able to successfully mount my usb device (a camera in this case) one time.  I can also successfully unmount it and nothing abnormal appears in dmesg.  However, upon physically removing the device the above data is displayed.  Then any new usb devices that are attached fail to be recognized (ie the /dev/sda1 is not created).

How sure are you that the problem is in the mm patchset?  I first experienced the problem in one of the later love patches (the first ones didn't experience this problem).  I am currently using 2.6.2-rc2-love4.  However, 2.6.1-mm4 does not for me have the same problem.  In fact, after I post this message I'm going to be booting back into my mm4 kernel.

Where have you been able to find other discussion about this?

Scott

----------

## sklettke

Yes.  The USB in mm4 works perfectly.

Here's what I get now when I remove my USB mouse.

```
usb 1-2: USB disconnect, address 4

hub 1-0:1.0: new USB device on port 2, assigned address 5

input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:1d.0-2

```

Scott

----------

## tdb

I got the idea that it was mm related from a thread talking about the issue. I don't remember where that thread was. I found the discussions by googling for any variation of the following keywords:

```

khubd usb mass storage oops "releasing anticipatory io scheduler"

```

I haven't had time to try any other kernels. This problem exists on two different machines for me; so I don't think it's a hardware issue for me. I can't figure out why more people have this problem. Are none of the other people who have love sources using USB mass storage? (other then you and me?)

----------

## sklettke

It must be one of the patches that the love-sources apply.  I'm currently running 2.6.2-mm1 and usb-storage works perfectly in it.  As shown here, https://forums.gentoo.org/viewtopic.php?t=132765&highlight=lovesources, 2.6.2-mm1 is one of the patches, among others, that the latest love-source uses.  I'd suggest emerging mm-sources until the love-sources get it worked out.

Scott

----------

## tdb

I wonder if it isn't either the scheduler, or Reiser4. I've been meaning to experiment with those two. I sort of recall there being some unique, custom scheduler patch added shortly before this problem cropped up. 

Steel, if you're reading this, does that make any sense?

----------

## Pink

It's not just a love-sources thing. It is a general problem that I ask about here:

anyone got usb working in 2.6+

I think it is two problems:

Firstly, Is your flash drive fat or fat32? My usb stick is (was) and it couldn't be mounted, I changed it to reiserfs and it mounted perfectly well - not much use when the computers at University use windows, but it is a start - on other forums it is mentioned that the fat driver in 2.6 is too strict....

Secondly, it is the unmounting matter; if one unplugs the usb stick, a reboot or restart of hotplug is required for it to be recognised again when plugging it back in.

No answers I know but a problem that is palgueing a hell of a lot of 2.6 users... I want my love-sources   :Crying or Very sad: 

[edit]

sklettke: I just noticed your post in love-sources - I willl try 2.6.2-mm1 and try the usb-storage, if it does work on mine that'll be great but very intrigueing as it doesn't in 2.6.0 or 2.6.1 - I'll let you know.

[edit2]

Mmmm, it does work a bit better in 2.6.2-mm1, I can replug it in with it being recognised, but it will not mount it with fat or fat 32... it will mount it with reiserfs. At least I know they do work and I'll keep on trying.Last edited by Pink on Mon Feb 09, 2004 8:45 am; edited 1 time in total

----------

## tdb

 *PickledOnion wrote:*   

> 
> 
> Firstly, Is your flash drive fat or fat32? 

 

I think mine is fat. I remember reformatting it into the lowest level ms windows compatability I could find. (ultimate goal being to mount it loopback in KNoppix so I can carry some software with me.) I think it's more then that, though, because my GF's digital camera does the same thing, and that's in Fat 32. It's definitely something that happened around 2.6.1; because I was able to download from the camera with no problems at that time.

----------

## sklettke

 *PickledOnion wrote:*   

> 
> 
> Mmmm, it does work a bit better in 2.6.2-mm1, I can replug it in with it being recognised, but it will not mount it with fat or fat 32... it will mount it with reiserfs. At least I know they do work and I'll keep on trying.

 

Hmm.  For me, 2.6.2-mm1 works prefectly for my usb-storage devices.  I am able to mount it (it's fat), unmount it, physically remove it, and then reinsert it and mount it again.

I may try the latest love-sources that just came out https://forums.gentoo.org/viewtopic.php?t=134412&postdays=0&postorder=asc&start=0.  It uses 2.6.3-rc1-mm1.  I'll let you know how it goes.

Scott

----------

## sklettke

Just tried this with the 2.6.2-ck1 kernel

USB-storage is also correctly working in this version.  The latest love-sources, 2.6.3_rc1-love1, still include a patch that makes the usb-storage not work.

Scott

----------

## Pink

@ sklettke: Many thanks for the info - I'll try some other 2.6+ and see how they go. The ck looks good but the warning about the HT hack concerns me (as I am using an athlon).

Anyway, I digress... happy kernel hunting.

----------

## darkless

Well, I did some testing to locate the error, as my usb-storage bailed out as well using latest dark-sources (my own spinoff/lite version of love-sources) and I found out which patch causes it to b0rk:

It's Nick Piggin's elv-select patch (runtime I/O sheduler selection) that wreaks havoc. You'll need to reverse the patch in order to fix the problem.

If you still want to use the CFQ scheduler after reversing the elv-select patch, you'll have to remove the anticipatory scheduler from your kernel, otherwise it'll take precedence of CFQ.

----------

## tdb

 *darkless wrote:*   

> Well, I did some testing to locate the error, as my usb-storage bailed out as well using latest dark-sources (my own spinoff/lite version of love-sources) and I found out which patch causes it to b0rk:
> 
> It's Nick Piggin's elv-select patch (runtime I/O sheduler selection) that wreaks havoc. You'll need to reverse the patch in order to fix the problem.
> 
> If you still want to use the CFQ scheduler after reversing the elv-select patch, you'll have to remove the anticipatory scheduler from your kernel, otherwise it'll take precedence of CFQ.

 

Great, I kind of liked that feature. Anyone know where Steel keeps the individual patches so I can back this thing out?

----------

## Pink

Well then, as soon as we find the patch it's goodbye to Nick Piggin's elv-select...

Many thanks to everyone working on this, these forums are great  :Very Happy: 

Now to find the patch!

----------

## darkless

Since you ask so nicely, this one should do the trick (this is the regular patch, you need to reverse it):

http://www.sundebo.dk/dark-sources/911_nick-elv-select.patch

----------

## sklettke

 *darkless wrote:*   

> Since you ask so nicely, this one should do the trick (this is the regular patch, you need to reverse it):
> 
> http://www.sundebo.dk/dark-sources/911_nick-elv-select.patch

 

Great.  Thanks!  Once the elv-select patch is reversed, how do you get CFQ to be the primary scheduler?

[EDIT] BTW, Steel300 released a compilation of all the individual patches of love-sources here: http://www.linuxmall.us/~lovepatch/love-sources/[/EDIT]

Scott

----------

## Regor

If anyone who follows this thread hasn't noticed yet, the newest love-sources (2.6.3-rc2-love2) have left out the elv-select patch.

My camera is happy again.  :Smile: 

----------

