In cases where the entire xenstore device key is removed, FdoScan()
currently skips reenumeration entirely. This causes it to not pass the
removal event to xennet. Fix the issue by reenumerating devices even if
xenstore key does not exist.
Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
Name = PdoGetName(Pdo);
Missing = TRUE;
Name = PdoGetName(Pdo);
Missing = TRUE;
- // If the PDO already exists and its name is in the device list
- // then we don't want to remove it.
- for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
- PANSI_STRING Device = &Devices[Index];
-
- if (Device->Length == 0)
- continue;
-
- if (strcmp(Name, Device->Buffer) == 0) {
- Missing = FALSE;
- Device->Length = 0; // avoid duplication
- break;
+ if (Devices != NULL) {
+ // If the PDO already exists and its name is in the device list
+ // then we don't want to remove it.
+ for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
+ PANSI_STRING Device = &Devices[Index];
+
+ if (Device->Length == 0)
+ continue;
+
+ if (strcmp(Name, Device->Buffer) == 0) {
+ Missing = FALSE;
+ Device->Length = 0; // avoid duplication
+ break;
+ }
}
// Walk the class list and create PDOs for any new device
}
// Walk the class list and create PDOs for any new device
- for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
- PANSI_STRING Device = &Devices[Index];
+ if (Devices != NULL) {
+ for (Index = 0; Devices[Index].Buffer != NULL; Index++) {
+ PANSI_STRING Device = &Devices[Index];
- if (Device->Length != 0) {
- ULONG Number;
- CHAR Prefix[sizeof ("device/vif/XXXXXXXXXX")];
- PCHAR Address;
+ if (Device->Length != 0) {
+ ULONG Number;
+ CHAR Prefix[sizeof ("device/vif/XXXXXXXXXX")];
+ PCHAR Address;
- Number = strtol(Device->Buffer, NULL, 10);
+ Number = strtol(Device->Buffer, NULL, 10);
- status = RtlStringCbPrintfA(Prefix,
- sizeof (Prefix),
- "device/vif/%u",
- Number);
- ASSERT(NT_SUCCESS(status));
- if (!NT_SUCCESS(status))
- continue;
-
- status = XENBUS_STORE(Read,
- &Fdo->StoreInterface,
- NULL,
- Prefix,
- "mac",
- &Address);
- if (!NT_SUCCESS(status))
- continue;
+ status = RtlStringCbPrintfA(Prefix,
+ sizeof (Prefix),
+ "device/vif/%u",
+ Number);
+ ASSERT(NT_SUCCESS(status));
+ if (!NT_SUCCESS(status))
+ continue;
- status = PdoCreate(Fdo, Number, Address);
- if (NT_SUCCESS(status))
- NeedInvalidate = TRUE;
+ status = XENBUS_STORE(Read,
+ &Fdo->StoreInterface,
+ NULL,
+ Prefix,
+ "mac",
+ &Address);
+ if (!NT_SUCCESS(status))
+ continue;
- XENBUS_STORE(Free,
- &Fdo->StoreInterface,
- Address);
+ status = PdoCreate(Fdo, Number, Address);
+ if (NT_SUCCESS(status))
+ NeedInvalidate = TRUE;
+
+ XENBUS_STORE(Free,
+ &Fdo->StoreInterface,
+ Address);
+ }
- if (Devices == NULL)
- goto loop;
+ if (Devices == NULL) {
+ if (status == STATUS_OBJECT_PATH_NOT_FOUND)
+ goto invalidate;
+ else
+ goto loop;
+ }
if (ParametersKey != NULL) {
status = RegistryQuerySzValue(ParametersKey,
if (ParametersKey != NULL) {
status = RegistryQuerySzValue(ParametersKey,
if (UnsupportedDevices != NULL)
RegistryFreeSzValue(UnsupportedDevices);
if (UnsupportedDevices != NULL)
RegistryFreeSzValue(UnsupportedDevices);
NeedInvalidate = __FdoEnumerate(Fdo, Devices);
NeedInvalidate = __FdoEnumerate(Fdo, Devices);
- __FdoFreeAnsi(Devices);
+ if (Devices != NULL)
+ __FdoFreeAnsi(Devices);
if (NeedInvalidate) {
NeedInvalidate = FALSE;
if (NeedInvalidate) {
NeedInvalidate = FALSE;