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 B734378049F for ; Tue, 25 Jul 2023 08:45:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6EESbOXybXtHDWXL6QipkFYS2zadon0NIgwwjwSUzCE=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690274714; v=1; b=czq3xwfcL9AWH+Uv6LwdpGGnmD1KPLOKeid9EIoKvTeDksqwKMBo3S+eYYNkz5/NG+0t5yZS cJWQct29tkJb0wIscv/98mRak+4jN5DIoyc1mq54hq3+CmdG7rjTG8OHG0PwoQueeDNFoku5VUO bSHhXYfpEm6qArM4+ao4Kh30= X-Received: by 127.0.0.2 with SMTP id mIwvYY7687511xFvSO46XuM3; Tue, 25 Jul 2023 01:45:14 -0700 X-Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) by mx.groups.io with SMTP id smtpd.web10.16013.1690274713726343365 for ; Tue, 25 Jul 2023 01:45:13 -0700 X-Received: by mail-vk1-f175.google.com with SMTP id 71dfb90a1353d-48133dc9820so1715214e0c.3 for ; Tue, 25 Jul 2023 01:45:13 -0700 (PDT) X-Gm-Message-State: hPVGobYAbdAWtZ0VUU6mVJSrx7686176AA= X-Google-Smtp-Source: APBJJlHTnBNd6rHCVqlTgjopf5/+bQYfJcdLEH6IT+zRTHsYOpsDrnwA1xFe2VcdYLkK1ROTvtDLT8P6MTCBrFuCvCk= X-Received: by 2002:a1f:3d0d:0:b0:486:43d0:90d6 with SMTP id k13-20020a1f3d0d000000b0048643d090d6mr76928vka.1.1690274712471; Tue, 25 Jul 2023 01:45:12 -0700 (PDT) MIME-Version: 1.0 References: <20230725011037.2229-1-wangyzhaoz@163.com> In-Reply-To: <20230725011037.2229-1-wangyzhaoz@163.com> From: "Pedro Falcato" Date: Tue, 25 Jul 2023 09:45:01 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH] Silicon/Synopsys/DesignWare: DwEmacSnpDxe: Fix bug in EmacGetDmaStatus To: devel@edk2.groups.io, wangyzhaoz@163.com Cc: Leif Lindholm , Ard Biesheuvel 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,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" 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=czq3xwfc; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.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 On Tue, Jul 25, 2023 at 2:10=E2=80=AFAM wrote: > > 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/DwEmacSnpDx= e.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 =3D 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 =3D 0; > + UINT32 DmaStatus; > + UINT32 ErrorBit; > + UINT32 Mask =3D 0; > + EFI_STATUS Status =3D EFI_SUCCESS; > + > + if (IrqStat =3D=3D NULL) { > + Status =3D EFI_INVALID_PARAMETER; > + goto EXIT; > + } This patch looks bogus to me. IrqStat is marked OPTIONAL, how can you error out if it isn't provided? Also, please CC maintainers next time. > > DmaStatus =3D 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/10719= 5 > Mute This Topic: https://groups.io/mt/100342205/5946980 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [pedro.falcato@gmail.co= m] > ------------ > > --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107226): https://edk2.groups.io/g/devel/message/107226 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-