diff options
author | Stephen Warren <swarren@nvidia.com> | 2014-07-23 04:06:46 +0400 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-08-09 19:17:02 +0400 |
commit | ded2e20ef281e5ff7921fbb3b74113ea33e8e309 (patch) | |
tree | a686b29f2953d7d147315296ad776c65b1af14c4 /common/cmd_pxe.c | |
parent | 183cbff706476d75e3cb92d1332c94ff4958b4bd (diff) | |
download | u-boot-ded2e20ef281e5ff7921fbb3b74113ea33e8e309.tar.xz |
pxe: clear Bootfile before returning
When "pxe boot" downloads the initrd/kernel/DTB, netboot_common() saves
the downloaded filename to global variable BootFile. If the boot
operation is aborted, this global state is not cleared. If "dhcp" is
executed later without any arguments, BootFile is not cleared, and when
the DHCP response is received, BootpCopyNetParams() writes the value into
environment variable bootfile.
This causes the following scenario:
* Boot script executes dhcp; pxe get; pxe boot
* User CTRL-C's the PXE menu, which causes the first menu item to be
booted, which causes some file to be downloaded.
(This boot-on-CTRL-C behaviour is arguably a bug too, but it's a
separate bug and the bug this patch fixes would still exist if the user
simply waited to press CTRL-C until "pxe boot" started downloading
files)
* User CTRL-C's the file downloads, but the filename is still written to
the bootfile environment variable.
* User re-runs the boot command, which in my case executes "dhcp; pxe get;
pxe boot" again, and "dhcp" picks up the saved bootfile environment
variable and proceeds to download a file that it shouldn't.
To solve this, modify the implementation of "pxe get" to clear BootFile
if the whole boot operation fails, which avoids this whole mess.
An alternative would be to modify netboot_common() such that the no-
arguments case explicitly clears the global variable BootFile. However,
that would prevent the following command sequences from working:
$ dhcp filename # downloads "filename"
$ dhcp # downloads $bootfile, i.e. "filename"
or:
$ setenv bootfile filename
$ dhcp # downloads $bootfile, i.e. "filename"
... and I assume someone relies on U-Boot working that way.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'common/cmd_pxe.c')
-rw-r--r-- | common/cmd_pxe.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index ba48692e86..28999f5734 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -1554,6 +1554,8 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) destroy_pxe_menu(cfg); + copy_filename(BootFile, "", sizeof(BootFile)); + return 0; } |