1
0
mirror of https://github.com/bobranten/Ext4Fsd.git synced 2026-03-15 21:00:37 -05:00

add timeouts to remaining infinite waits in pnp.c and fsctl.c

The previous commit missed three infinite KeWaitForSingleObject calls:

- pnp.c: Ext2PnpRemove and Ext2PnpSurpriseRemove wait forever for the
  lower driver to complete the PnP IRP after device removal
- fsctl.c: Ext2IsMediaWriteProtected waits forever for the
  write-protect check IRP to complete

All three now use 30-second timeouts with IRP cancellation on timeout,
matching the pattern used in block.c.
This commit is contained in:
HorusGod
2026-03-05 00:59:24 +02:00
parent d0f12d766a
commit 5c01ce9f00
2 changed files with 40 additions and 9 deletions

View File

@@ -2019,14 +2019,22 @@ Ext2IsMediaWriteProtected (
Status = IoCallDriver(TargetDevice, Irp);
if (Status == STATUS_PENDING) {
LARGE_INTEGER Timeout;
Timeout.QuadPart = (LONGLONG)-30 * 10 * 1000 * 1000; /* 30 seconds */
(VOID) KeWaitForSingleObject( &Event,
Status = KeWaitForSingleObject( &Event,
Executive,
KernelMode,
FALSE,
(PLARGE_INTEGER)NULL );
&Timeout );
Status = IoStatus.Status;
if (Status == STATUS_TIMEOUT) {
IoCancelIrp(Irp);
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = STATUS_IO_TIMEOUT;
} else {
Status = IoStatus.Status;
}
}
return (BOOLEAN)(Status == STATUS_MEDIA_WRITE_PROTECTED);

View File

@@ -198,11 +198,20 @@ Ext2PnpQueryRemove (
IrpContext->Irp);
if (Status == STATUS_PENDING) {
KeWaitForSingleObject( &Event,
LARGE_INTEGER Timeout;
Timeout.QuadPart = (LONGLONG)-30 * 10 * 1000 * 1000; /* 30 seconds */
Status = KeWaitForSingleObject( &Event,
Executive,
KernelMode,
FALSE,
NULL );
&Timeout );
if (Status == STATUS_TIMEOUT) {
IoCancelIrp(IrpContext->Irp);
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
}
Status = IrpContext->Irp->IoStatus.Status;
}
@@ -270,12 +279,19 @@ Ext2PnpRemove (
IrpContext->Irp);
if (Status == STATUS_PENDING) {
LARGE_INTEGER Timeout;
Timeout.QuadPart = (LONGLONG)-30 * 10 * 1000 * 1000; /* 30 seconds */
KeWaitForSingleObject( &Event,
Status = KeWaitForSingleObject( &Event,
Executive,
KernelMode,
FALSE,
NULL );
&Timeout );
if (Status == STATUS_TIMEOUT) {
IoCancelIrp(IrpContext->Irp);
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
}
Status = IrpContext->Irp->IoStatus.Status;
}
@@ -342,12 +358,19 @@ Ext2PnpSurpriseRemove (
IrpContext->Irp);
if (Status == STATUS_PENDING) {
LARGE_INTEGER Timeout;
Timeout.QuadPart = (LONGLONG)-30 * 10 * 1000 * 1000; /* 30 seconds */
KeWaitForSingleObject( &Event,
Status = KeWaitForSingleObject( &Event,
Executive,
KernelMode,
FALSE,
NULL );
&Timeout );
if (Status == STATUS_TIMEOUT) {
IoCancelIrp(IrpContext->Irp);
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
}
Status = IrpContext->Irp->IoStatus.Status;
}