From nobody Mon Dec 23 19:23:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515036059155852.8780446109927; Wed, 3 Jan 2018 19:20:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C541C222D1547; Wed, 3 Jan 2018 19:15:53 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CFFC422280C5B for ; Wed, 3 Jan 2018 19:15:51 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:23 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:22 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="21245822" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:05 +0800 Message-Id: <1515036008-10700-2-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 1/4] NetworkPkg: Add ASSERT error handling for UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wang Fan In Udp6Dxe, there are several places use ASSERT to check returned value. But these errors should be handled if they occur, this patch is to fix this issue. Cc: Ye Ting Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Impl.c | 16 +++++++++++++++- NetworkPkg/Udp6Dxe/Udp6Main.c | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index edf2c23..25d4e6a 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -1,9 +1,9 @@ /** @file Udp6 driver's whole implementation. =20 - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -1606,10 +1606,14 @@ Udp6Demultiplex ( // // Get the datagram header from the packet buffer. // Udp6Header =3D (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + NetbufFree (Packet); + return; + } =20 if (Udp6Header->Checksum !=3D 0) { // // check the checksum. // @@ -1716,10 +1720,13 @@ Udp6SendPortUnreach ( // // Get the Ipv6 Mode Data. // Ip6ModeData =3D AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA)); ASSERT (Ip6ModeData !=3D NULL); + if (Ip6ModeData =3D=3D NULL) { + goto EXIT; + } =20 // // If not finding the related IpSender use the default IpIo to send out // the port unreachable ICMP message. // @@ -1764,10 +1771,13 @@ Udp6SendPortUnreach ( // // Allocate space for the IP6_ICMP_ERROR_HEAD. // IcmpErrHdr =3D (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FA= LSE); ASSERT (IcmpErrHdr !=3D NULL); + if (IcmpErrHdr =3D=3D NULL) { + goto EXIT; + } =20 // // Set the required fields for the icmp port unreachable message. // IcmpErrHdr->Head.Type =3D ICMP_V6_DEST_UNREACHABLE; @@ -1845,10 +1855,14 @@ Udp6IcmpHandler ( return; } =20 Udp6Header =3D (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + NetbufFree (Packet); + return; + } =20 IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source); IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest); =20 Udp6Session.SourcePort =3D NTOHS (Udp6Header->DstPort); diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index f3e9925..9105ef4 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -1,9 +1,9 @@ /** @file Contains all EFI_UDP6_PROTOCOL interfaces. =20 - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -523,10 +523,15 @@ Udp6Transmit ( Udp6Service =3D Instance->Udp6Service; *((UINTN *) &Packet->ProtoData[0]) =3D (UINTN) (Udp6Service->IpIo); =20 Udp6Header =3D (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_= SIZE, TRUE); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + =20 ConfigData =3D &Instance->ConfigData; =20 // // Fill the udp header. // --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 19:23:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515036061112991.7577960620724; Wed, 3 Jan 2018 19:21:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 26F13222D154A; Wed, 3 Jan 2018 19:15:54 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9106122280C5B for ; Wed, 3 Jan 2018 19:15:52 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:25 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:24 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="21245829" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:06 +0800 Message-Id: <1515036008-10700-3-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 2/4] NetworkPkg: Fix a memory leak issue in UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wang Fan In UDP6Dxe Udp6Groups(), the code return directly without free the buffer allocated for McastIp when JoinFlag is TRUE. It is a memory leak issue that needs to be fixed. This patch is to fix this issue. Cc: Ye Ting Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index 9105ef4..8495bc3 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -349,10 +349,13 @@ Udp6Groups ( } } =20 Instance =3D UDP6_INSTANCE_DATA_FROM_THIS (This); if (!Instance->Configured) { + if (McastIp !=3D NULL) { + FreePool (McastIp); + } return EFI_NOT_STARTED; } =20 Ip =3D Instance->IpInfo->Ip.Ip6; =20 --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 19:23:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515036064097564.917152089613; Wed, 3 Jan 2018 19:21:04 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 88F3E222D1540; Wed, 3 Jan 2018 19:15:57 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 71294222A54F4 for ; Wed, 3 Jan 2018 19:15:56 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:28 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:27 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="21245835" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:07 +0800 Message-Id: <1515036008-10700-4-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 3/4] NetworkPkg: Fix some coding style issues in UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wang Fan In UDP6Dxe, there are some coding style issues, this patch is to fix these issues. Cc: Ye Ting Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Driver.c | 20 ++++++++++---------- NetworkPkg/Udp6Dxe/Udp6Impl.c | 10 ++++++---- NetworkPkg/Udp6Dxe/Udp6Main.c | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Drive= r.c index a4b1104..6dde1fc 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Driver.c +++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c @@ -1,9 +1,9 @@ /** @file Driver Binding functions and Service Binding functions for the Network d= river module. =20 - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -162,11 +162,10 @@ Udp6DriverBindingStart ( &Udp6Service->ServiceBinding, NULL ); if (EFI_ERROR (Status)) { Udp6CleanService (Udp6Service); - goto EXIT; } =20 EXIT: if (EFI_ERROR (Status)) { if (Udp6Service !=3D NULL) { @@ -180,12 +179,13 @@ EXIT: Callback function which provided by user to remove one node in NetDestro= yLinkList process. =20 @param[in] Entry The entry to be removed. @param[in] Context Pointer to the callback context correspond= s to the Context in NetDestroyLinkList. =20 - @retval EFI_SUCCESS The entry has been removed successfully. - @retval Others Fail to remove the entry. + @retval EFI_INVALID_PARAMETER Entry is NULL or Context is NULL. + @retval EFI_SUCCESS The entry has been removed successfully. + @retval Others Fail to remove the entry. =20 **/ EFI_STATUS EFIAPI Udp6DestroyChildEntryInHandleBuffer ( @@ -241,16 +241,16 @@ Udp6DriverBindingStop ( IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_HANDLE NicHandle; - EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; - UDP6_SERVICE_DATA *Udp6Service; - LIST_ENTRY *List; - UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; + EFI_STATUS Status; + EFI_HANDLE NicHandle; + EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; + UDP6_SERVICE_DATA *Udp6Service; + LIST_ENTRY *List; + UDP6_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; =20 // // Find the NicHandle where UDP6 ServiceBinding Protocol is installed. // NicHandle =3D NetLibGetNicHandle (ControllerHandle, &gEfiIp6ProtocolGuid= ); diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index 25d4e6a..458470c 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -156,11 +156,12 @@ Udp6RecycleRxDataWrap ( @param[in] Packet Pointer to the buffer containing the rece= ived datagram. @param[in] RxData Pointer to the EFI_UDP6_RECEIVE_DATA of t= his datagram. =20 - @return Pointer to the structure wrapping the RxData and the Packet. + @return Pointer to the structure wrapping the RxData and the Packet. NUL= L will + be returned if any error occurs. =20 **/ UDP6_RXDATA_WRAP * Udp6WrapRxData ( IN UDP6_INSTANCE_DATA *Instance, @@ -1372,11 +1373,12 @@ Udp6RecycleRxDataWrap ( @param[in] Packet Pointer to the buffer containing the rece= ived datagram. @param[in] RxData Pointer to the EFI_UDP6_RECEIVE_DATA of t= his datagram. =20 - @return Pointer to the structure wrapping the RxData and the Packet. + @return Pointer to the structure wrapping the RxData and the Packet. NUL= L will + be returned if any error occurs. =20 **/ UDP6_RXDATA_WRAP * Udp6WrapRxData ( IN UDP6_INSTANCE_DATA *Instance, @@ -1596,11 +1598,11 @@ Udp6Demultiplex ( UINT16 HeadSum; EFI_UDP6_RECEIVE_DATA RxData; EFI_UDP6_SESSION_DATA *Udp6Session; UINTN Enqueued; =20 - if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) { + if (Packet->TotalSize < UDP6_HEADER_SIZE) { NetbufFree (Packet); return; } =20 // @@ -1848,11 +1850,11 @@ Udp6IcmpHandler ( EFI_UDP_HEADER *Udp6Header; EFI_UDP6_SESSION_DATA Udp6Session; LIST_ENTRY *Entry; UDP6_INSTANCE_DATA *Instance; =20 - if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) { + if (Packet->TotalSize < UDP6_HEADER_SIZE) { NetbufFree (Packet); return; } =20 Udp6Header =3D (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index 8495bc3..53145c3 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -583,11 +583,11 @@ Udp6Transmit ( Udp6Header->Checksum =3D Udp6Checksum (Packet, HeadSum); if (Udp6Header->Checksum =3D=3D 0) { // // If the calculated checksum is 0, fill the Checksum field with a= ll ones. // - Udp6Header->Checksum =3D 0XFFFF; + Udp6Header->Checksum =3D 0xffff; } } else { // // Set the checksum is zero if the ConfigData->StationAddress is uns= pcified // and the Ipv6 will fill the correct value of this checksum. --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Dec 23 19:23:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151503606715547.91096551037958; Wed, 3 Jan 2018 19:21:07 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DE9BB222D1550; Wed, 3 Jan 2018 19:15:59 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB569222D154D for ; Wed, 3 Jan 2018 19:15:57 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:30 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:29 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="21245843" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:08 +0800 Message-Id: <1515036008-10700-5-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 4/4] NetworkPkg: Add more parameter or return status check in UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Wang Fan In UDP6Dxe, there are several places that may be enhanced to check input parameters and returned status. This patch is to fix these issues. Cc: Ye Ting Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Driver.c | 48 +++++++++++++++++++++++--------------= ---- NetworkPkg/Udp6Dxe/Udp6Impl.c | 17 +++++++++++++++ NetworkPkg/Udp6Dxe/Udp6Main.c | 2 +- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/NetworkPkg/Udp6Dxe/Udp6Driver.c b/NetworkPkg/Udp6Dxe/Udp6Drive= r.c index 6dde1fc..f9d528e 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Driver.c +++ b/NetworkPkg/Udp6Dxe/Udp6Driver.c @@ -288,22 +288,19 @@ Udp6DriverBindingStop ( Udp6DestroyChildEntryInHandleBuffer, &Context, NULL ); } else if (IsListEmpty (&Udp6Service->ChildrenList)) { - gBS->UninstallMultipleProtocolInterfaces ( - NicHandle, - &gEfiUdp6ServiceBindingProtocolGuid, - &Udp6Service->ServiceBinding, - NULL - ); + Status =3D gBS->UninstallMultipleProtocolInterfaces ( + NicHandle, + &gEfiUdp6ServiceBindingProtocolGuid, + &Udp6Service->ServiceBinding, + NULL + ); =20 Udp6CleanService (Udp6Service); - FreePool (Udp6Service); - - Status =3D EFI_SUCCESS; } =20 return Status; } =20 @@ -508,25 +505,34 @@ Udp6ServiceBindingDestroyChild ( Instance->InDestroy =3D TRUE; =20 // // Close the Ip6 protocol on the default IpIo. // - gBS->CloseProtocol ( - Udp6Service->IpIo->ChildHandle, - &gEfiIp6ProtocolGuid, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle - ); + Status =3D gBS->CloseProtocol ( + Udp6Service->IpIo->ChildHandle, + &gEfiIp6ProtocolGuid, + gUdp6DriverBinding.DriverBindingHandle, + Instance->ChildHandle + ); + if (EFI_ERROR (Status)) { + Instance->InDestroy =3D FALSE; + return Status; + } + // // Close the Ip6 protocol on this instance's IpInfo. // - gBS->CloseProtocol ( - Instance->IpInfo->ChildHandle, - &gEfiIp6ProtocolGuid, - gUdp6DriverBinding.DriverBindingHandle, - Instance->ChildHandle - ); + Status =3D gBS->CloseProtocol ( + Instance->IpInfo->ChildHandle, + &gEfiIp6ProtocolGuid, + gUdp6DriverBinding.DriverBindingHandle, + Instance->ChildHandle + ); + if (EFI_ERROR (Status)) { + Instance->InDestroy =3D FALSE; + return Status; + } =20 // // Uninstall the Udp6Protocol previously installed on the ChildHandle. // Status =3D gBS->UninstallMultipleProtocolInterfaces ( diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index 458470c..d014e2d 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -55,10 +55,13 @@ Udp6FindInstanceByPort ( /** This function is the packet transmitting notify function registered to t= he IpIo interface. It's called to signal the udp TxToken when the IpIo layer com= pletes transmitting of the udp datagram. =20 + If Context is NULL, then ASSERT(). + If NotifyData is NULL, then ASSERT(). + @param[in] Status The completion status of the output udp da= tagram. @param[in] Context Pointer to the context data. @param[in] Sender Specify a EFI_IP6_PROTOCOL for sending. @param[in] NotifyData Pointer to the notify data. =20 @@ -73,10 +76,14 @@ Udp6DgramSent ( ); =20 /** This function processes the received datagram passed up by the IpIo laye= r. =20 + If NetSession is NULL, then ASSERT(). + If Packet is NULL, then ASSERT(). + If Context is NULL, then ASSERT(). + @param[in] Status The status of this udp datagram. @param[in] IcmpError The IcmpError code, only available when St= atus is EFI_ICMP_ERROR. @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. @param[in] Packet Pointer to the NET_BUF containing the rece= ived udp @@ -975,10 +982,13 @@ Udp6RemoveToken ( /** This function is the packet transmitting notify function registered to t= he IpIo interface. It's called to signal the udp TxToken when IpIo layer complet= es the transmitting of the udp datagram. =20 + If Context is NULL, then ASSERT(). + If NotifyData is NULL, then ASSERT(). + @param[in] Status The completion status of the output udp da= tagram. @param[in] Context Pointer to the context data. @param[in] Sender Specify a EFI_IP6_PROTOCOL for sending. @param[in] NotifyData Pointer to the notify data. =20 @@ -993,10 +1003,12 @@ Udp6DgramSent ( ) { UDP6_INSTANCE_DATA *Instance; EFI_UDP6_COMPLETION_TOKEN *Token; =20 + ASSERT (Context !=3D NULL && NotifyData !=3D NULL); + Instance =3D (UDP6_INSTANCE_DATA *) Context; Token =3D (EFI_UDP6_COMPLETION_TOKEN *) NotifyData; =20 if (Udp6RemoveToken (&Instance->TxTokens, Token) =3D=3D EFI_SUCCESS) { // @@ -1010,10 +1022,14 @@ Udp6DgramSent ( =20 =20 /** This function processes the received datagram passed up by the IpIo laye= r. =20 + If NetSession is NULL, then ASSERT(). + If Packet is NULL, then ASSERT(). + If Context is NULL, then ASSERT(). + @param[in] Status The status of this udp datagram. @param[in] IcmpError The IcmpError code, only available when St= atus is EFI_ICMP_ERROR. @param[in] NetSession Pointer to the EFI_NET_SESSION_DATA. @param[in] Packet Pointer to the NET_BUF containing the rece= ived udp @@ -1029,10 +1045,11 @@ Udp6DgramRcvd ( IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context ) { + ASSERT (NetSession !=3D NULL && Packet !=3D NULL && Context !=3D NULL); NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE); =20 // // IpIo only passes received packets with Status EFI_SUCCESS or EFI_ICMP= _ERROR. // diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index 53145c3..1d7f0ac 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -379,11 +379,11 @@ Udp6Groups ( if (JoinFlag) { =20 Status =3D NetMapInsertTail (&Instance->McastIps, (VOID *) McastIp, NU= LL); } else { =20 - NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, MulticastAddress); + Status =3D NetMapIterate (&Instance->McastIps, Udp6LeaveGroup, Multica= stAddress); } =20 ON_EXIT: =20 gBS->RestoreTPL (OldTpl); --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel