From: Stefan Roese Date: Fri, 17 Nov 2017 07:47:09 +0000 (+0100) Subject: efi_loader: Exit in efi_set_bootdev() upon invalid "desc" X-Git-Tag: v2018.01-rc2~58^2~22 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8300be612cda2ae0a07bcc513d00e3b99b7f5f6f;p=oweals%2Fu-boot.git efi_loader: Exit in efi_set_bootdev() upon invalid "desc" When trying to load an image from a non-existent USB key, U-Boot v2017.11 crashes on my x86 platform: => load usb 0:1 03000000 abc General Protection EIP: 0010:[<7b59030d>] EFLAGS: 00010286 Original EIP :[] ... This used to work in v2017.09. Testing has shown, that this bug was introduced with patch 95c5553e [efi_loader: refactor boot device and loaded_image handling]. This patch now checks if a valid "desc" is returned from blk_get_dev() and only continues when "desc" is available. Resulting in this cmd output (again): => load usb 0:1 03000000 abc ** Bad device usb 0 ** Signed-off-by: Stefan Roese Reviewed-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 67855ba685..aa754b75cd 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -436,6 +436,8 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path) int part; desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10)); + if (!desc) + return; part = parse_partnum(devnr); bootefi_device_path = efi_dp_from_part(desc, part);