All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spl: fit: Skip attempting to load 0 length image
@ 2021-10-19 17:32 Nishanth Menon
  2021-10-20  5:12 ` Aswath Govindraju
  2021-12-02 12:14 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Nishanth Menon @ 2021-10-19 17:32 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Aswath Govindraju, Tarun, Nishanth Menon

When, for various reasons, a bad FIT image is used where a loadable
image is marked as 0 length, attempt is made for a 0 length allocation and
read of 0 byte read operation.

Instead provide warning in log and skip attempting to do such a load.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 common/spl/spl_fit.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index f41abca0ccb5..e9540dc2167a 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -286,6 +286,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 		if (fit_image_get_data_size(fit, node, &len))
 			return -ENOENT;
 
+		/* Dont bother to copy 0 byte data, but warn, though */
+		if (!len) {
+			log_warning("%s: Skip load '%s': image size is 0!\n",
+				    __func__, fit_get_name(fit, node, NULL));
+			return 0;
+		}
+
 		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
 		length = len;
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spl: fit: Skip attempting to load 0 length image
  2021-10-19 17:32 [PATCH] spl: fit: Skip attempting to load 0 length image Nishanth Menon
@ 2021-10-20  5:12 ` Aswath Govindraju
  2021-12-02 12:14 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Aswath Govindraju @ 2021-10-20  5:12 UTC (permalink / raw)
  To: Nishanth Menon, Tom Rini; +Cc: u-boot, Tarun

On 19/10/21 11:02 pm, Nishanth Menon wrote:
> When, for various reasons, a bad FIT image is used where a loadable
> image is marked as 0 length, attempt is made for a 0 length allocation and
> read of 0 byte read operation.
> 
> Instead provide warning in log and skip attempting to do such a load.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---

Reviewed-by: Aswath Govindraju <a-govindraju@ti.com>

Thanks,
Aswath

>  common/spl/spl_fit.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index f41abca0ccb5..e9540dc2167a 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -286,6 +286,13 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  		if (fit_image_get_data_size(fit, node, &len))
>  			return -ENOENT;
>  
> +		/* Dont bother to copy 0 byte data, but warn, though */
> +		if (!len) {
> +			log_warning("%s: Skip load '%s': image size is 0!\n",
> +				    __func__, fit_get_name(fit, node, NULL));
> +			return 0;
> +		}
> +
>  		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
>  		length = len;
>  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spl: fit: Skip attempting to load 0 length image
  2021-10-19 17:32 [PATCH] spl: fit: Skip attempting to load 0 length image Nishanth Menon
  2021-10-20  5:12 ` Aswath Govindraju
@ 2021-12-02 12:14 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-12-02 12:14 UTC (permalink / raw)
  To: Nishanth Menon; +Cc: u-boot, Aswath Govindraju, Tarun

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

On Tue, Oct 19, 2021 at 12:32:29PM -0500, Nishanth Menon wrote:

> When, for various reasons, a bad FIT image is used where a loadable
> image is marked as 0 length, attempt is made for a 0 length allocation and
> read of 0 byte read operation.
> 
> Instead provide warning in log and skip attempting to do such a load.
> 
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Aswath Govindraju <a-govindraju@ti.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-02 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 17:32 [PATCH] spl: fit: Skip attempting to load 0 length image Nishanth Menon
2021-10-20  5:12 ` Aswath Govindraju
2021-12-02 12:14 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.