From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 2DC4E740034 for ; Tue, 25 Jul 2023 01:10:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Pdb6Y60QLGdRHOgcNvrju293BHI1DNT3F7jj8OlAkew=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:From:To:Cc:Subject:Date:Message-Id:MIME-Version:X-CM-TRANSID:X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1690247449; v=1; b=XRIO8mmqZtH5S8TE8foONHA3GJ9RLoMaB/cNYiNx9KlMsmpvNnMoN5lJzF7NfhmqNkF2d5Rq f9o3aFhA6y3+zThHA048W1T65kucJwcttpZ4iKDzlvvU39VhJr31skjajweRUSmMySUnMe8zM4T VpNkEQ1ho0uSSAu/zn7m8ZeQ= X-Received: by 127.0.0.2 with SMTP id 5YDkYY7687511xCt3OINzeO1; Mon, 24 Jul 2023 18:10:49 -0700 X-Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.214]) by mx.groups.io with SMTP id smtpd.web11.10999.1690247447473492606 for ; Mon, 24 Jul 2023 18:10:48 -0700 X-Received: from localhost.localdomain (unknown [219.141.235.82]) by zwqz-smtp-mta-g3-1 (Coremail) with SMTP id _____wAXtCgPIb9k94TqBA--.52099S2; Tue, 25 Jul 2023 09:10:40 +0800 (CST) From: wangyzhaoz@163.com To: devel@edk2.groups.io Cc: Yang Wang Subject: [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus Date: Tue, 25 Jul 2023 09:10:37 +0800 Message-Id: <20230725011037.2229-1-wangyzhaoz@163.com> MIME-Version: 1.0 X-CM-TRANSID: _____wAXtCgPIb9k94TqBA--.52099S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxXrWkAF47Ar43KrW7Gr1DGFg_yoW5Jw13pa 4kAr42kr4rGa13ZFy3Aa4YgF15AFyxWrWkA3sFy3ZIqF13JFWUuw1xuFWaq3WDWF1rJay3 GF9Yq34xCF1ayaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRFeH-UUUUU= X-Originating-IP: [219.141.235.82] X-CM-SenderInfo: 5zdqw5p2kd06i6rwjhhfrp/1tbioxG3JWNfu436igAAsa Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wangyzhaoz@163.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: idkbGZh7vnRbcRXGqXFImc9dx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=XRIO8mmq; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=163.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Yang Wang Check EmacGetDmaStatus input parameters IrqStat may be a null pointer. Signed-off-by: Yang Wang --- .../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 ( }=0D =0D // Check DMA Irq status=0D - EmacGetDmaStatus (IrqStat, Snp->MacBase);=0D + Status =3D EmacGetDmaStatus (IrqStat, Snp->MacBase);=0D + if (EFI_ERROR(Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a: error Status: %r\n", __func__, Status));=0D + }=0D =0D - return EFI_SUCCESS;=0D + return Status;=0D }=0D =0D =0D 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 ( }=0D =0D =0D -VOID=0D +EFI_STATUS=0D EFIAPI=0D EmacGetDmaStatus (=0D OUT UINT32 *IrqStat OPTIONAL,=0D IN UINTN MacBaseAddress=0D )=0D {=0D - UINT32 DmaStatus;=0D - UINT32 ErrorBit;=0D - UINT32 Mask =3D 0;=0D + UINT32 DmaStatus;=0D + UINT32 ErrorBit;=0D + UINT32 Mask =3D 0;=0D + EFI_STATUS Status =3D EFI_SUCCESS;=0D +=0D + if (IrqStat =3D=3D NULL) {=0D + Status =3D EFI_INVALID_PARAMETER;=0D + goto EXIT;=0D + }=0D =0D DmaStatus =3D MmioRead32 (MacBaseAddress +=0D DW_EMAC_DMAGRP_STATUS_OFST);=0D @@ -602,6 +608,8 @@ EmacGetDmaStatus ( MmioOr32 (MacBaseAddress +=0D DW_EMAC_DMAGRP_STATUS_OFST,=0D Mask);=0D +EXIT:=0D + return Status;=0D }=0D =0D =0D 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 ( );=0D =0D =0D -VOID=0D +EFI_STATUS=0D EFIAPI=0D EmacGetDmaStatus (=0D OUT UINT32 *IrqStat OPTIONAL,=0D --=20 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] -=-=-=-=-=-=-=-=-=-=-=-