[edk2-devel] [edk2-platforms PATCH 5/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpGetStatus

Marcin Wojtas mw at semihalf.com
Mon Mar 14 15:38:34 UTC 2022


This patch adds missing parameter's and SNP instance
status checks in SnpGetStatus callback.

Signed-off-by: Marcin Wojtas <mw at semihalf.com>
---
 Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 31 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
index 91cd573b87..8a4c4545c8 100644
--- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
+++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
@@ -991,16 +991,43 @@ Pp2SnpGetStatus (
   OUT VOID                       **TxBuf OPTIONAL
   )
 {
-  PP2DXE_CONTEXT *Pp2Context = INSTANCE_FROM_SNP(Snp);
-  PP2DXE_PORT *Port = &Pp2Context->Port;
+  PP2DXE_CONTEXT *Pp2Context;
+  PP2DXE_PORT *Port;
   BOOLEAN LinkUp;
   EFI_TPL SavedTpl;
 
+  /* Check Snp Instance. */
+  if (Snp == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
+  Pp2Context = INSTANCE_FROM_SNP (Snp);
+
+  /* Check whether the driver was started and initialized. */
+  if (Snp->Mode->State != EfiSimpleNetworkInitialized) {
+    switch (Snp->Mode->State) {
+    case EfiSimpleNetworkStopped:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not started\n", Pp2Context->Instance));
+      ReturnUnlock (SavedTpl, EFI_NOT_STARTED);
+    case EfiSimpleNetworkStarted:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not initialized\n", Pp2Context->Instance));
+      ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);
+    default:
+      DEBUG ((DEBUG_WARN,
+        "Pp2Dxe%d: wrong state: %u\n",
+        Pp2Context->Instance,
+        Snp->Mode->State));
+      ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);
+    }
+  }
+
   if (!Pp2Context->Initialized)
     ReturnUnlock(SavedTpl, EFI_NOT_READY);
 
+  Port = &Pp2Context->Port;
+
   LinkUp = Port->AlwaysUp ? TRUE : MvGop110PortIsLinkUp(Port);
 
   if (LinkUp != Snp->Mode->MediaPresent) {
-- 
2.29.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87544): https://edk2.groups.io/g/devel/message/87544
Mute This Topic: https://groups.io/mt/89776255/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list