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

Conversation

santhoshkumarvenkatachalam
Copy link
Contributor

Resolved INTEGER_OVERFLOW Coverity Issues in MNP Dxe 1.MnpStop,MnpInstanceDeliverPacket
Expression "MnpDeviceData->ConfiguredChildrenNumber--" and Instance->RcvdPacketQueueSize-- where Both variables are known to be equal to 0,underflows the type that receives it.

Description

Resolved INTEGER_OVERFLOW Coverity Issues in MNP Dxe
1.MnpStop,MnpInstanceDeliverPacket
Expression "MnpDeviceData->ConfiguredChildrenNumber--" and
Instance->RcvdPacketQueueSize-- where Both variables are known
to be equal to 0,underflows the type that receives it.

Signed-off-by: santhosh kumar V <santhoshkumarv@ami.com>
@@ -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?

@@ -1305,6 +1305,10 @@ MnpStop (
MnpDeviceData = MnpServiceData->MnpDeviceData;
ASSERT (MnpDeviceData->ConfiguredChildrenNumber > 0);

if (MnpDeviceData->ConfiguredChildrenNumber <= 0) {
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.

@@ -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.

@@ -325,6 +325,9 @@ MnpInstanceDeliverPacket (
}

ASSERT (Instance->RcvdPacketQueueSize != 0);
if (Instance->RcvdPacketQueueSize <= 0) {
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants