From ed5d71ab06bf45e585f9d03049f4730109979aff Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 20 Oct 2017 19:00:56 +0200 Subject: arm: bootm: don't fall over if image is padded with less than 40 bytes If the zImage has a padding, which is less than 40 bytes (sizeof struct fdt_header) the amount of read bytes would be propagated as an error code. Fix this by only propagating real errors and treating failure to read less than the expected amount as no concatenated DT being present. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- arch/arm/lib/bootm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 8068a53be0..25efb42541 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -250,8 +250,10 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data) header = &__header; ret = read(fd, header, sizeof(*header)); - if (ret < sizeof(*header)) + if (ret < 0) return ret; + if (ret < sizeof(*header)) + return -ENXIO; if (file_detect_type(header, sizeof(*header)) != filetype_oftree) return -ENXIO; -- cgit v1.2.3