From: Daniel Palmer Date: Sat, 31 Aug 2024 03:17:06 +0000 (+0900) Subject: spl: spl_load: fix comparison between negative error code and unsigned size X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=c6eba28c467bea645040789c17d50f04637f4771;p=u-boot.git spl: spl_load: fix comparison between negative error code and unsigned size read could be a negative error value but size in spl_image is unsigned so when they are compared read is used as if it's a unsigned value and if it's negative it'll most likely be bigger than size and the result will be true and _spl_load() will return 0 to the caller. This results in the caller to _spl_load() not seeing that an error happened as it should and continuing as if the load was completed when it might not have been. Check if read is negative and return it's value if it is before comparing against size in spl_image. Signed-off-by: Daniel Palmer Reviewed-by: Simon Glass --- diff --git a/include/spl_load.h b/include/spl_load.h index 83db381202..935f7d336f 100644 --- a/include/spl_load.h +++ b/include/spl_load.h @@ -83,6 +83,10 @@ static inline int _spl_load(struct spl_image_info *spl_image, read = info->read(info, offset + image_offset, size, map_sysmem(spl_image->load_addr - overhead, size)); + + if (read < 0) + return read; + return read < spl_image->size ? -EIO : 0; }