From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=104.47.0.43; helo=eur01-he1-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0043.outbound.protection.outlook.com [104.47.0.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 93D2B20355213 for ; Tue, 7 Nov 2017 21:11:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VgBz57XGJvOV85bvgutWeKRMujRThhi2yH8k1HNfoTo=; b=o8XB/viaQ6gEGsNhrJDOjdMcbDfsQ/zVsILLPXHXVPZTqbjtdDmMrSoLg7jNTU5smS2Iyl45P7AEr+cR0nTD1d+/ucMSfXF4SSRaa54DDlXn01Ci7yFEwxV8xGGG7P+cAbAaXVc0lYVinY6+U9gnf1LlwBEzeYV9YGmcVpfN+xg= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by DBXPR04MB304.eurprd04.prod.outlook.com (10.141.232.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Wed, 8 Nov 2017 05:15:56 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::7cbb:e077:2ee1:20f0]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::7cbb:e077:2ee1:20f0%13]) with mapi id 15.20.0197.020; Wed, 8 Nov 2017 05:15:49 +0000 From: Udit Kumar To: Leif Lindholm , Vabhav Sharma CC: "edk2-devel@lists.01.org" , "ruiyu.ni@intel.com" , "jaben.carsey@intel.com" , "ard.biesheuvel@linaro.org" , "siyuan.fu@intel.com" , "ting.ye@intel.com" Thread-Topic: [PATCH] Tftp assert fix for openfile failure case Thread-Index: AQHTVH7+4kDHbRbEhEawzI/JXsGRxKMJOhCAgAC5yNA= Date: Wed, 8 Nov 2017 05:15:49 +0000 Message-ID: References: <1509719192-16582-1-git-send-email-vabhav.sharma@nxp.com> <20171107175458.f4pgne4rkri7lzch@bivouac.eciton.net> In-Reply-To: <20171107175458.f4pgne4rkri7lzch@bivouac.eciton.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DBXPR04MB304; 6:ZkKypSCYAKF0TbsR0C2S7N6L4YxlyUqWSEwjrTOmc5i0ANKaGntKt9L8sJG4VehoiTFAn5Es04e2p0cT+jUBxE745fsbUAdMq88AMcOmkcxUAEuPC5bcsjmlZQyH4V6E0ZcS/LOq78YvxBghYQPbiC6yC4cwJDy2LRk923TDObU7hIljGgckbjHYKCGXb93Uk38G4f3miuQNo61aYRsCCjwLsdfMljq9MWaW6qTLVe4mKSsAHIwuOAh8fWF395q5MF0XNeqY6B62H+uVqkaSRACYCbiai+JKO3KGZIUrRmLDdW+5aluUZ3wa4tsx681JAZ7GaonuvW6sFjoL7caxSgzlkLaYtPKOx2FJYg74eTo=; 5:iKgJrg09ppJjSQKSBCnMehHI3hUfuttECOb7qjlRIq6UNk5oj6urh4uhwLN+bZfnBFV0YG8vobaj1JRLwwqwnVtN0K2jG0UkOUCWbyR3O/AdqsFyU9GpkD/1VTW/BaO5Nnu6UEFIP6NGHGHuE75lf+UteumvDgrka+aoHHY8lMQ=; 24:daAIInWDt+J4M8cFC0k6PkMslLLr+pRDIzodB8DDp+/X2NXSunezEE98x2prtWDbvd7xiJvLTD9SH9sk4CyEPXUM8Uby03bTemx3vDeDC+E=; 7:vHwIy79lyb6CkhOug601poeZdULaJtDRlHkfADIPqMwm9ChX1Sffq/aelrfwe2mw296BlCXs+insnf7dqBHnz4RJlS0IwfY7SCFf1sJQecOEvAk+dQPLgRdVKrO1VcpA2kuQylIiBF7wcoYIPR0bNYwna5J5rL5BoKvKl8EdVlelnCZRsa8yxV0pDaTpW2WHoLLL63dI1b31/lR2IMTWjgWfs56Am+oJOAi2LLgBMgKpmwIl+/QtSbDLVWg4sE0T x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(189002)(199003)(13464003)(24454002)(97736004)(229853002)(9686003)(105586002)(8936002)(74316002)(478600001)(6116002)(3846002)(102836003)(54906003)(6246003)(66066001)(4326008)(106356001)(25786009)(6636002)(50986999)(305945005)(5250100002)(54356999)(53546010)(2906002)(6436002)(2950100002)(2900100001)(8676002)(99286004)(7736002)(110136005)(189998001)(86362001)(316002)(7696004)(81156014)(3280700002)(68736007)(3660700001)(101416001)(81166006)(6506006)(76176999)(33656002)(5660300001)(14454004)(55016002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR04MB304; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; x-ms-office365-filtering-correlation-id: 4a6e42da-3aa7-4318-2082-08d52667c676 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603249); SRVR:DBXPR04MB304; x-ms-traffictypediagnostic: DBXPR04MB304: x-exchange-antispam-report-test: UriScan:(185117386973197)(162533806227266)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3231021)(93006095)(93001095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DBXPR04MB304; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DBXPR04MB304; x-forefront-prvs: 0485417665 received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a6e42da-3aa7-4318-2082-08d52667c676 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Nov 2017 05:15:49.5441 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR04MB304 Subject: Re: [PATCH] Tftp assert fix for openfile failure case X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 05:12:01 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Leif Lindholm [mailto:leif.lindholm@linaro.org] > Sent: Tuesday, November 07, 2017 11:25 PM > To: Vabhav Sharma > Cc: edk2-devel@lists.01.org; ruiyu.ni@intel.com; jaben.carsey@intel.com; > ard.biesheuvel@linaro.org; siyuan.fu@intel.com; ting.ye@intel.com; Udit > Kumar > Subject: Re: [PATCH] Tftp assert fix for openfile failure case >=20 > On Fri, Nov 03, 2017 at 07:56:32PM +0530, Vabhav wrote: > > Issue: > > when file open is failed, assert was seen due to freeing 0 size page > > > > Reason: > > DataSize is remain zero if error is reported in ShellOpenFileByName > > > > Fix: > > Update DataSize as soon as FileSize is available > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Udit Kumar > > Signed-off-by: Vabhav > > --- > > ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c > > b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c > > index fbde3bf..6425fc5 100755 > > --- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c > > +++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c > > @@ -509,6 +509,7 @@ ShellCommandRunTftp ( > > ); > > goto NextHandle; >=20 > Wow, a goto in a foor loop in a 320-line function. > What could possibly go wrong? Instead of being on some volume, if you are on Shell.=20 Then file open will fail.=20 =20 > > } > > + DataSize =3D FileSize; > > > > Status =3D DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePa= th, > FileSize, BlockSize, &Data); > > if (EFI_ERROR (Status)) { > > @@ -539,7 +540,6 @@ ShellCommandRunTftp ( > > goto NextHandle; > > } > > > > - DataSize =3D FileSize; > > Status =3D ShellWriteFile (FileHandle, &FileSize, Data); > > if (!EFI_ERROR (Status)) { > > ShellStatus =3D SHELL_SUCCESS; > > -- > > 1.9.1 >=20 > So, a wider question: > This shell command was introduced in the heyday of "let's reimplement U-B= oot > in the EDK2 tree". Mainly, from my impression, it seems to be used in ord= er that > people don't need to learn how boot managers and device paths work. When you say about complete boot, then this may not be useful.=20 > Am I being too harsh? > Are there practical uses for this? For doing some sort of unit testing of given interface. I found this useful= . During development, this is useful to transfer generic file to development = board.=20 > Or should we delete it from the tree? =20 =20 > If the code is to be kept, I think (from a quick glance) that I would als= o like to see > *Data =3D NULL in the error path of DownloadFile(). >=20 > / > Leif