public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus
@ 2023-07-18  7:07 wangyzhaoz
  0 siblings, 0 replies; 8+ messages in thread
From: wangyzhaoz @ 2023-07-18  7:07 UTC (permalink / raw)
  To: devel; +Cc: Yang Wang, Michael D Kinney, Loh Tien Hock, Ooi Tzy Way, Ran Wang

From: Yang Wang <wangyzhaoz@163.com>

Check EmacGetDmaStatus input parameters
IrqStat may be a null pointer.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Loh Tien Hock <tien.hock.loh@intel.com>
Cc: Ooi Tzy Way <tzy.way.ooi@intel.com>
Cc: Ran Wang <wangran@bosc.ac.cn>

Signed-off-by: Yang Wang <wangyzhaoz@163.com>
---
 .../Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c          |  7 +++++--
 .../Drivers/DwEmacSnpDxe/EmacDxeUtil.c           | 16 ++++++++++++----
 .../Drivers/DwEmacSnpDxe/EmacDxeUtil.h           |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
index 4cb3371d79..6805511a1d 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
@@ -847,9 +847,12 @@ SnpGetStatus (
   }
 
   // Check DMA Irq status
-  EmacGetDmaStatus (IrqStat, Snp->MacBase);
+  Status = EmacGetDmaStatus (IrqStat, Snp->MacBase);
+  if (EFI_ERROR(Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: error  Status: %r\n", __func__, Status));
+  }
 
-  return EFI_SUCCESS;
+  return Status;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
index 3b982ce984..45b5a05f51 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
@@ -489,16 +489,22 @@ EmacDmaStart (
 }
 
 
-VOID
+EFI_STATUS
 EFIAPI
 EmacGetDmaStatus (
   OUT  UINT32   *IrqStat  OPTIONAL,
   IN   UINTN    MacBaseAddress
   )
 {
-  UINT32  DmaStatus;
-  UINT32  ErrorBit;
-  UINT32  Mask = 0;
+  UINT32        DmaStatus;
+  UINT32        ErrorBit;
+  UINT32        Mask = 0;
+  EFI_STATUS    Status = EFI_SUCCESS;
+
+  if (IrqStat == NULL) {
+    Status = EFI_INVALID_PARAMETER;
+    goto EXIT;
+  }
 
   DmaStatus = MmioRead32 (MacBaseAddress +
                            DW_EMAC_DMAGRP_STATUS_OFST);
@@ -602,6 +608,8 @@ EmacGetDmaStatus (
   MmioOr32 (MacBaseAddress +
             DW_EMAC_DMAGRP_STATUS_OFST,
             Mask);
+EXIT:
+  return Status;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
index c4c3653dc7..60f30ecd16 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
@@ -339,7 +339,7 @@ EmacDmaStart (
   );
 
 
-VOID
+EFI_STATUS
 EFIAPI
 EmacGetDmaStatus (
   OUT UINT32                  *IrqStat  OPTIONAL,
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106986): https://edk2.groups.io/g/devel/message/106986
Mute This Topic: https://groups.io/mt/100212047/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus
@ 2023-07-25  1:10 wangyzhaoz
  2023-07-25  8:45 ` Pedro Falcato
  0 siblings, 1 reply; 8+ messages in thread
From: wangyzhaoz @ 2023-07-25  1:10 UTC (permalink / raw)
  To: devel; +Cc: Yang Wang

From: Yang Wang <wangyzhaoz@163.com>

Check EmacGetDmaStatus input parameters
IrqStat may be a null pointer.

Signed-off-by: Yang Wang <wangyzhaoz@163.com>
---
 .../Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c          |  7 +++++--
 .../Drivers/DwEmacSnpDxe/EmacDxeUtil.c           | 16 ++++++++++++----
 .../Drivers/DwEmacSnpDxe/EmacDxeUtil.h           |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
index 4cb3371d79..6805511a1d 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c
@@ -847,9 +847,12 @@ SnpGetStatus (
   }
 
   // Check DMA Irq status
-  EmacGetDmaStatus (IrqStat, Snp->MacBase);
+  Status = EmacGetDmaStatus (IrqStat, Snp->MacBase);
+  if (EFI_ERROR(Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: error  Status: %r\n", __func__, Status));
+  }
 
-  return EFI_SUCCESS;
+  return Status;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
index 3b982ce984..45b5a05f51 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.c
@@ -489,16 +489,22 @@ EmacDmaStart (
 }
 
 
-VOID
+EFI_STATUS
 EFIAPI
 EmacGetDmaStatus (
   OUT  UINT32   *IrqStat  OPTIONAL,
   IN   UINTN    MacBaseAddress
   )
 {
-  UINT32  DmaStatus;
-  UINT32  ErrorBit;
-  UINT32  Mask = 0;
+  UINT32        DmaStatus;
+  UINT32        ErrorBit;
+  UINT32        Mask = 0;
+  EFI_STATUS    Status = EFI_SUCCESS;
+
+  if (IrqStat == NULL) {
+    Status = EFI_INVALID_PARAMETER;
+    goto EXIT;
+  }
 
   DmaStatus = MmioRead32 (MacBaseAddress +
                            DW_EMAC_DMAGRP_STATUS_OFST);
@@ -602,6 +608,8 @@ EmacGetDmaStatus (
   MmioOr32 (MacBaseAddress +
             DW_EMAC_DMAGRP_STATUS_OFST,
             Mask);
+EXIT:
+  return Status;
 }
 
 
diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
index c4c3653dc7..60f30ecd16 100755
--- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
+++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/EmacDxeUtil.h
@@ -339,7 +339,7 @@ EmacDmaStart (
   );
 
 
-VOID
+EFI_STATUS
 EFIAPI
 EmacGetDmaStatus (
   OUT UINT32                  *IrqStat  OPTIONAL,
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107195): https://edk2.groups.io/g/devel/message/107195
Mute This Topic: https://groups.io/mt/100342205/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-28  3:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18  7:07 [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus wangyzhaoz
  -- strict thread matches above, loose matches on Subject: below --
2023-07-25  1:10 wangyzhaoz
2023-07-25  8:45 ` Pedro Falcato
2023-07-26  3:07   ` wangy
2023-07-27  0:26     ` Pedro Falcato
2023-07-27  7:11       ` wangy
2023-07-27 13:45         ` Pedro Falcato
2023-07-28  3:55           ` wangy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox