Skip to content
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

NetworkPkg:Resolved Coverity Issues in MnpDxe #10680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NetworkPkg/MnpDxe/MnpConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,10 @@ MnpStop (
MnpDeviceData = MnpServiceData->MnpDeviceData;
ASSERT (MnpDeviceData->ConfiguredChildrenNumber > 0);

if (MnpDeviceData->ConfiguredChildrenNumber <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfiguredChildrenNumber is UINTN - does this change not generate a new Coverity warning?

return EFI_OUT_OF_RESOURCES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not feel like an appropriate return code.

Also, if we look at the call path, if we return an error here, we will fall back all the way to MnpConfigure which will itself pass this return value on.

But the documentation for MnpConfigure says that for "Others" error codes (as well as for EFI_OUT_OF_RESOURCES), "The MNP child driver instance has been reset to startup defaults.".
But I don't see anything like that happening as a result of this patch.
And given this error could only ever be triggered if the driver state ended up inconcistent, that would feel like an important thing to do.

}

//
// Configure the receive filters.
//
Expand Down
3 changes: 3 additions & 0 deletions NetworkPkg/MnpDxe/MnpIo.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ MnpInstanceDeliverPacket (
}

ASSERT (Instance->RcvdPacketQueueSize != 0);
if (Instance->RcvdPacketQueueSize <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also UINTN.

return EFI_OUT_OF_RESOURCES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not feel like an appropriate return value on finding that the packet queue is empty and there is nothing to deliver.

}

RxDataWrap = NET_LIST_HEAD (&Instance->RcvdPacketQueue, MNP_RXDATA_WRAP, WrapEntry);
if (RxDataWrap->Nbuf->RefCnt > 2) {
Expand Down
Loading