From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web08.27467.1647272338987838684 for ; Mon, 14 Mar 2022 08:38:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20210112.gappssmtp.com header.s=20210112 header.b=jKsGLeL/; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.167.47, mailfrom: mw@semihalf.com) Received: by mail-lf1-f47.google.com with SMTP id bt26so27901896lfb.3 for ; Mon, 14 Mar 2022 08:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xyY9c748TdQe2ZqFTqZu+tVlggvQ1x1K6CMbpPfvfjU=; b=jKsGLeL/7qHV35+iaeW9HBSORe0VyJ4aW/gNTa/Fxogd+LgycjABDy59BD7XtIZkH6 E5+oDV4dc0DIdWB8K3XRApT5RLVK4c7yowHx49el9lxfW9CCUDj12PDoM+ctTlxTyLmB KUjW1pXJ+Nq5/5O+uDeLs9fSOiCjYvOJ+AuQFD4zbI2Zi0tR4uNt5Sm1l51WYAIxckmC AXcDh/xi0E3gWAiNRt1/80LE0TtNyNEIcQXckLbapdXn57HSRAg3qJ4Bz5+P7W98gYM1 aauEdbbGs1L0DGs2GPrMK7VeOnKS604KV/e0H7d6LHr0rP8eo6U/4Vvd6EKLkELab2Oi uWaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xyY9c748TdQe2ZqFTqZu+tVlggvQ1x1K6CMbpPfvfjU=; b=V1WqsDrmhFWwT5uvSdJj0U7Z4Rp9zDo78RwlMDkx8Gko2sTANx3wuxhDPTDlsjzPcj uiLsYwSUEns/wjvGCd0RAojTI2kkerYAhy48Ta3UpScq863CyGzg/Y8jRGgWdAePpcJE Xz9zRKOTtwl4/tB+FARg4CzBrmfzLvzIEaFqB45XvyEuYh6e+hCyceF6UmeL9seTNaP9 CGrvwkzjWJHQGIKOeu8jrFM5khrb3Xs6yhLRYRduDySMgKtFr7u0as+KXn1bJZj9Q18P iWRyBKJnvoPiT55ch7bF3M2eNbAWfnQvJ0EB8Xmhrs4JhW7OcBkCO83ujLSpRQwhleus uguQ== X-Gm-Message-State: AOAM533cV6411KJ2L45QHCIDjxDxr1/qj4ES6KVRH46gTH96Mqgmq2bV KysfhTM1LsAtCXyFyOnZZtIGTHKA2UTLQg== X-Google-Smtp-Source: ABdhPJz/FdmpoORZkqwSmN17PVLoC2P43JodCrkShMN0jyPOEwFNOEqRPz0dkS4EVwc127a3GiKC9A== X-Received: by 2002:a05:6512:308e:b0:448:5d75:9729 with SMTP id z14-20020a056512308e00b004485d759729mr13312078lfd.663.1647272337238; Mon, 14 Mar 2022 08:38:57 -0700 (PDT) Return-Path: Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id b8-20020ac25628000000b004484bd1be5esm3325401lff.256.2022.03.14.08.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 08:38:56 -0700 (PDT) From: "Marcin Wojtas" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, ardb+tianocore@kernel.org, mw@semihalf.com, jaz@semihalf.com, gjb@semihalf.com, upstream@semihalf.com, sunny.Wang@arm.com Subject: [edk2-platforms PATCH 6/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpTransmit Date: Mon, 14 Mar 2022 16:38:35 +0100 Message-Id: <20220314153837.1885852-7-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20220314153837.1885852-1-mw@semihalf.com> References: <20220314153837.1885852-1-mw@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Error checking for invalid input parameters was too hard. Replace ASSERT with returning error value. Moreover set EtherType only when we are sure it won't be dereferencing NULL pointer. Signed-off-by: Marcin Wojtas --- Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 8a4c4545c8..deb3f34625 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c @@ -1074,9 +1074,15 @@ Pp2SnpTransmit ( }=0D =0D if (HeaderSize !=3D 0) {=0D - ASSERT (HeaderSize =3D=3D This->Mode->MediaHeaderSize);=0D - ASSERT (EtherTypePtr !=3D NULL);=0D - ASSERT (DestAddr !=3D NULL);=0D + if (HeaderSize !=3D This->Mode->MediaHeaderSize ||=0D + EtherTypePtr =3D=3D NULL ||=0D + DestAddr =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D + }=0D +=0D + if (BufferSize < This->Mode->MediaHeaderSize) {=0D + return EFI_BUFFER_TOO_SMALL;=0D }=0D =0D SavedTpl =3D gBS->RaiseTPL (TPL_CALLBACK);=0D @@ -1100,8 +1106,6 @@ Pp2SnpTransmit ( ReturnUnlock(SavedTpl, EFI_NOT_READY);=0D }=0D =0D - EtherType =3D HTONS (*EtherTypePtr);=0D -=0D /* Fetch next descriptor */=0D TxDesc =3D Mvpp2TxqNextDescGet(AggrTxq);=0D =0D @@ -1118,6 +1122,8 @@ Pp2SnpTransmit ( else=0D CopyMem(DataPtr + NET_ETHER_ADDR_LEN, &This->Mode->CurrentAddress, N= ET_ETHER_ADDR_LEN);=0D =0D + EtherType =3D HTONS (*EtherTypePtr);=0D +=0D CopyMem(DataPtr + NET_ETHER_ADDR_LEN * 2, &EtherType, 2);=0D }=0D =0D --=20 2.29.0