[Bug]: <Unclosed BlockIo2 Protocol during DiskIoDriverBindingStart Error Handling> #10727
Open
2 of 5 tasks
Labels
package:mdemodulepkg
priority:medium
Moderate impact. Should be prioritized over lower priority issues.
state:needs-maintainer-feedback
state:needs-triage
type:bug
Something isn't working
Is there an existing issue for this?
Bug Type
Code first?
What packages are impacted?
MdeModulePkg
Which targets are impacted by this bug?
No response
Current Behavior
During the DiskIoDriverBindingStart, both the BlockIo and BlockIo2 protocols are opened for the specified controller handle. The Instance->SharedWorkingBuffer is then allocated based on the BlockSize. If the BlockSize is zero, indicating that the handle does not support Read/Write operations, the buffer will not be allocated. A NULL check is performed on the SharedWorkingBuffer, and if it is NULL, the process jumps to the ErrorExit. In the ErrorExit section, only the BlockIo protocol is closed, while the BlockIo2 protocol remains open.
We are facing an issue with Uninstalling the BlockIo2 protocol during the DriverBindingStop process because it remains open.
MdeModulePkg\Universal\DiskIoDxe\DiskIo.c
ErrorExit:
if (EFI_ERROR (Status)) {
if ((Instance != NULL) && (Instance->SharedWorkingBuffer != NULL)) {
FreeAlignedPages (
Instance->SharedWorkingBuffer,
EFI_SIZE_TO_PAGES (PcdGet32 (PcdDiskIoDataBufferBlockNum) * Instance->BlockIo->Media->BlockSize)
);
}
if (Instance != NULL) {
FreePool (Instance);
}
gBS->CloseProtocol (
ControllerHandle,
&gEfiBlockIoProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
}
Expected Behavior
The check needs to be added for the BlockIo2 protocol in the ErrorExit, and it should be closed properly if the BlockIo2 protocol is opened.
Steps To Reproduce
LUN does not support Read/Write operations.
UFS WLUN handle and not closed.
Build Environment
Version Information
Urgency
Medium
Are you going to fix this?
I will fix it
Do you need maintainer feedback?
Maintainer feedback requested
Anything else?
Hi @niruiyu
Please verify the issue on your end and provide confirmation.
I have a fix ready and will create a PR with the necessary changes.
CC: @lgao4 @mdkinney
Thanks,
Kanagavel
The text was updated successfully, but these errors were encountered: