Don't call notification procedures with APC disabled, it may lead to some strange results.

Thanks Alex for the time he took to help me to debug this issue

svn path=/trunk/; revision=24085
This commit is contained in:
Hervé Poussineau 2006-09-12 21:18:22 +00:00
parent 3fd92a4f96
commit 6ed6c1661e

View file

@ -202,6 +202,7 @@ IopNotifyPlugPlayNotification(
IN PVOID EventCategoryData2) IN PVOID EventCategoryData2)
{ {
PPNP_NOTIFY_ENTRY ChangeEntry; PPNP_NOTIFY_ENTRY ChangeEntry;
PLIST_ENTRY ListEntry;
PVOID NotificationStructure; PVOID NotificationStructure;
BOOLEAN CallCurrentEntry; BOOLEAN CallCurrentEntry;
@ -265,9 +266,10 @@ IopNotifyPlugPlayNotification(
/* Loop through procedures registred in PnpNotifyListHead /* Loop through procedures registred in PnpNotifyListHead
* list to find those that meet some criteria. * list to find those that meet some criteria.
*/ */
ListEntry = PnpNotifyListHead.Flink;
LIST_FOR_EACH(ChangeEntry,&PnpNotifyListHead, PNP_NOTIFY_ENTRY, PnpNotifyList) while (ListEntry != &PnpNotifyListHead)
{ {
ChangeEntry = CONTAINING_RECORD(ListEntry, PNP_NOTIFY_ENTRY, PnpNotifyList);
CallCurrentEntry = FALSE; CallCurrentEntry = FALSE;
switch (EventCategory) switch (EventCategory)
@ -298,15 +300,22 @@ IopNotifyPlugPlayNotification(
} }
} }
/* Move to the next element now, as callback may unregister itself */
ListEntry = ListEntry->Flink;
/* FIXME: If ListEntry was the last element and that callback registers
* new notifications, those won't be checked... */
if (CallCurrentEntry) if (CallCurrentEntry)
{ {
/* Call entry into new allocated memory */ /* Call entry into new allocated memory */
DPRINT("IopNotifyPlugPlayNotification(): found suitable callback %p\n", DPRINT("IopNotifyPlugPlayNotification(): found suitable callback %p\n",
ChangeEntry); ChangeEntry);
KeReleaseGuardedMutex(&PnpNotifyListLock);
(ChangeEntry->PnpNotificationProc)( (ChangeEntry->PnpNotificationProc)(
NotificationStructure, NotificationStructure,
ChangeEntry->Context); ChangeEntry->Context);
KeAcquireGuardedMutex(&PnpNotifyListLock);
} }
} }