public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leif Lindholm <leif.lindholm@linaro.org>
To: Vabhav <vabhav.sharma@nxp.com>
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 <udit.kumar@nxp.com>
Subject: Re: [PATCH] Tftp assert fix for openfile failure case
Date: Tue, 7 Nov 2017 17:54:59 +0000	[thread overview]
Message-ID: <20171107175458.f4pgne4rkri7lzch@bivouac.eciton.net> (raw)
In-Reply-To: <1509719192-16582-1-git-send-email-vabhav.sharma@nxp.com>

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 <udit.kumar@nxp.com>
> Signed-off-by: Vabhav <vabhav.sharma@nxp.com>
> ---
>  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;

Wow, a goto in a foor loop in a 320-line function.
What could possibly go wrong?

>      }
> +    DataSize = FileSize;
>  
>      Status = DownloadFile (Mtftp4, RemoteFilePath, AsciiRemoteFilePath, FileSize, BlockSize, &Data);
>      if (EFI_ERROR (Status)) {
> @@ -539,7 +540,6 @@ ShellCommandRunTftp (
>        goto NextHandle;
>      }
>  
> -    DataSize = FileSize;
>      Status = ShellWriteFile (FileHandle, &FileSize, Data);
>      if (!EFI_ERROR (Status)) {
>        ShellStatus = SHELL_SUCCESS;
> -- 
> 1.9.1

So, a wider question:
This shell command was introduced in the heyday of "let's reimplement
U-Boot in the EDK2 tree". Mainly, from my impression, it seems to be
used in order that people don't need to learn how boot managers and
device paths work.
Am I being too harsh?
Are there practical uses for this?
Or should we delete it from the tree?

If the code is to be kept, I think (from a quick glance) that I would
also like to see *Data = NULL in the error path of DownloadFile().

/
    Leif


  reply	other threads:[~2017-11-07 17:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 14:26 [PATCH] Tftp assert fix for openfile failure case Vabhav
2017-11-07 17:54 ` Leif Lindholm [this message]
2017-11-08  5:15   ` Udit Kumar
2017-11-08 15:22     ` Leif Lindholm
2017-11-09  4:43       ` Udit Kumar
2018-02-13  9:43         ` Meenakshi Aggarwal
2018-02-13 15:14           ` Carsey, Jaben
2018-02-13 15:19             ` Meenakshi Aggarwal
2018-02-13 15:36               ` Carsey, Jaben
2018-02-20  6:19                 ` Meenakshi Aggarwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171107175458.f4pgne4rkri7lzch@bivouac.eciton.net \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox