From: Heinrich Schuchardt Date: Thu, 11 Apr 2019 19:26:59 +0200 Subject: [U-Boot] [PATCH 2/3] efi: add protection for block_dev In-Reply-To: <1554886979-22890-2-git-send-email-patrick.delaunay@st.com> References: <1554886979-22890-1-git-send-email-patrick.delaunay@st.com> <1554886979-22890-2-git-send-email-patrick.delaunay@st.com> Message-ID: <1080f421-9d51-b64a-e497-e8c608fb8fd5@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 4/10/19 11:02 AM, Patrick Delaunay wrote: > Check the value of block_dev before to use this pointer. > > This patch solves problem for the command "load" when ubifs > is previously mounted: in this case the function > blk_get_device_part_str("ubi 0") don't return error but return > block_dev = NULL and then data abort. > > Signed-off-by: Patrick Delaunay Reviewed-by: Heinrich Schuchardt Added to efi-2019-07 branch. > --- > > To reproduce the issue, I have a boot script 'boot.scr.uimg' > with a load command executed during ubi boot: > > load ${devtype} ${devnum}:${distro_bootpart} ${m4fw_addr} ${m4fw_name} > > I have a data abort for call stack: > - do_load_wrapper for "ubi 0" > -- efi_set_bootdev > --- efi_dp_from_name > > => desc = 0 and data abort for access to 'desc->*' > > I also proposed a protection for the same issue in ums command > http://patchwork.ozlabs.org/project/uboot/list/?series=68096 > > > lib/efi_loader/efi_device_path.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c > index 53b40c8..fd57be8 100644 > --- a/lib/efi_loader/efi_device_path.c > +++ b/lib/efi_loader/efi_device_path.c > @@ -970,7 +970,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, > if (!is_net) { > part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition, > 1); > - if (part < 0) > + if (part < 0 || !desc) > return EFI_INVALID_PARAMETER; > > if (device) >