[serial/VirtualSerial2] Complete WDFREQUEST on error paths in EvtIoWrite - #1422
Open
RKS (rksharma-owg) wants to merge 1 commit into
Open
RKS (rksharma-owg) wants to merge 1 commit into
RKS (rksharma-owg) wants to merge 1 commit into
Conversation
Ensure incoming write requests are completed with their failure NTSTATUS when WdfRequestRetrieveInputMemory or QueueProcessWriteBytes fails, preventing request leaks and caller hangs. Fixes microsoft#1375
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In
serial/VirtualSerial2/queue.c, theEvtIoWritecallback receives aWDFREQUEST Requestfrom the framework.Prior to this change, if
WdfRequestRetrieveInputMemoryfails (e.g., memory allocation failure) or ifQueueProcessWriteBytesfails (e.g., invalid write parameters),EvtIoWritelogged an error trace and executedreturn;without completing, forwarding, or storing theRequest.Under the Windows Driver Framework (KMDF), the driver is responsible for completing any request delivered to an I/O event callback unless the request is forwarded to another queue or marked cancelable/stored. Returning without completing the request causes the caller to hang indefinitely waiting for I/O completion and leaks the request object and associated framework resources.
This change calls
WdfRequestComplete(Request, status);before returning on both error exit paths inEvtIoWrite, matching KMDF request handling conventions and the error handling pattern used inEvtIoReadandEvtIoDeviceControl.Fixes #1375
Validation
windows-2025-vs2026(VS 2026 / WDK build environment).\Build-Samples.ps1serial.virtualserial2Debug x64: Succeeded (0 errors, 0 warnings)serial.virtualserial2Release x64: Succeeded (0 errors, 0 warnings)serial.virtualserial2Debug arm64: Succeeded (0 errors, 0 warnings)serial.virtualserial2Release arm64: Succeeded (0 errors, 0 warnings)