Unplug the usb power cause a system crash in winxp+sp2



I made a bda driver for our usb box. It seems working well until I
unplug the power wire when it running in winxp+sp2.(it saids that it
did not crash in win2k or winxp+sp1, so strange.)

In the read data routine, I insert the irp to a list and in the
complete routine I remove it from the list. Like this:
(I simply use the global variables.)
Insert:
--8<---------------cut here---------------start------------->8---
KeAcquireSpinLock(&g_ks_pl, &g_old_pk_irql);
InsertTailList(&g_irp_list, &p_irp->Tail.Overlay.ListEntry);
KeReleaseSpinLock(&g_ks_pl, g_old_pk_irql);

status = IoCallDriver(p_devobj, p_irp);
--8<---------------cut here---------------end--------------->8---
Removal:
--8<---------------cut here---------------start------------->8---
KeAcquireSpinLock(&g_ks_pl, &old_irql);

if (IsListEmpty(&g_irp_list))
{
KeReleaseSpinLock(&g_ks_pl, old_irql);
return FALSE;
}

RemoveHeadList(&g_irp_list);
KeReleaseSpinLock(&g_ks_pl, old_irql);
--8<---------------cut here---------------end--------------->8---

After I unplug the power of the usb, winxp+sp2 would crash in
usbport.sys. I commented out these codes, then unplug the power, no
crash.

I did not test the status of the irp, because I thought it was
useless. I simply insert the irp to the queue and remove it after it
completed.

Could some one tell me what's wrong with my code?
Advance thanks!

.



Relevant Pages

  • Re: Western Digital external HD & Adaptec enclosure problem
    ... Are both using USB for power? ... Unplug the Adaptec and the system runs normally. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Unplug the usb power cause a system crash in winxp+sp2
    ... >I made a bda driver for our usb box. ... > unplug the power wire when it running in winxp+sp2.(it saids that it ... > did not crash in win2k or winxp+sp1, ... > In the read data routine, I insert the irp to a list and in the ...
    (microsoft.public.development.device.drivers)
  • Re: Flames over -- Re: Which is simpler?
    ... that does not support standby power on USB broken if you wish... ... be okay to unplug a USB drive while the system is suspended? ...
    (Linux-Kernel)
  • Re: Power-management in mixed mode drivers
    ... In the very beginning of my USB driver development I decided to ... postpone power handler development and just forwarded any power IRP I ... IRP going down to USB bus driver on my device behalf, ...
    (microsoft.public.development.device.drivers)
  • Wake up promlem with Jaguar & MacG4?
    ... I am using a USB Apple keyboard with a Macally mouse plugged into ... If I unplug the mouse from the keyboard or unplug the keyboard and replug, ... There is power on the USB cable that I use because I can light up USB ...
    (comp.sys.mac.system)