-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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
type:bug
Something isn't working
Comments
kanagavels97
added a commit
to kanagavels97/edk2
that referenced
this issue
Feb 12, 2025
start. REF : tianocore#10727 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. branch Kanagavel/MdeModulePkg
kanagavels97
added a commit
to kanagavels97/edk2
that referenced
this issue
Feb 12, 2025
DiskIoDriverBindingStart. REF: tianocore#10727 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.
kanagavels97
added a commit
to kanagavels97/edk2
that referenced
this issue
Feb 13, 2025
REF: tianocore#10727 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. Signed-off-by: Kanagavel S <[email protected]>
kanagavels97
added a commit
to kanagavels97/edk2
that referenced
this issue
Feb 13, 2025
REF: tianocore#10727 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. Signed-off-by: Kanagavel S <[email protected]>
kanagavels97
added a commit
to kanagavels97/edk2
that referenced
this issue
Feb 13, 2025
REF: tianocore#10727 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. Signed-off-by: Kanagavel S <[email protected]>
I have left a comment in the PR. I think some additional code changes are required. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
package:mdemodulepkg
priority:medium
Moderate impact. Should be prioritized over lower priority issues.
state:needs-maintainer-feedback
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: