uboot-mediatek: fix determine the size of an uImage.FIT using 'imsz' or 'imszb'.
It must read the entire image for previous code of 'imsz' or 'imszb'. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com> Suggested-by: Chuanhong Guo <gch981213@gmail.com> (cherry picked from commit 3bbc1d5fba1d700917138334a48c16bafdf48de9)
This commit is contained in:
		 Jianhui Zhao
					Jianhui Zhao
				
			
				
					committed by
					
						 Daniel Golle
						Daniel Golle
					
				
			
			
				
	
			
			
			 Daniel Golle
						Daniel Golle
					
				
			
						parent
						
							89184b15cf
						
					
				
				
					commit
					1157b8c1f1
				
			| @@ -70,7 +70,7 @@ | |||||||
|  { |  { | ||||||
| --- a/boot/image-fit.c | --- a/boot/image-fit.c | ||||||
| +++ b/boot/image-fit.c | +++ b/boot/image-fit.c | ||||||
| @@ -2051,6 +2051,49 @@ static const char *fit_get_image_type_pr | @@ -2051,6 +2051,47 @@ static const char *fit_get_image_type_pr | ||||||
|  	return "unknown"; |  	return "unknown"; | ||||||
|  } |  } | ||||||
|   |   | ||||||
| @@ -93,11 +93,8 @@ | |||||||
| +	max_size = hdrsize; | +	max_size = hdrsize; | ||||||
| + | + | ||||||
| +	images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); | +	images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH); | ||||||
| +	if (images_noffset < 0) { | +	if (images_noffset < 0) | ||||||
| +		printf("Can't find images parent node '%s' (%s)\n", | +		goto out; | ||||||
| +		FIT_IMAGES_PATH, fdt_strerror(images_noffset)); |  | ||||||
| +		return 0; |  | ||||||
| +	} |  | ||||||
| + | + | ||||||
| +	for (ndepth = 0, | +	for (ndepth = 0, | ||||||
| +	     noffset = fdt_next_node(fit, images_noffset, &ndepth); | +	     noffset = fdt_next_node(fit, images_noffset, &ndepth); | ||||||
| @@ -106,7 +103,7 @@ | |||||||
| +		if (ndepth == 1) { | +		if (ndepth == 1) { | ||||||
| +			ret = fit_image_get_data_and_size(fit, noffset, &data, &data_size); | +			ret = fit_image_get_data_and_size(fit, noffset, &data, &data_size); | ||||||
| +			if (ret) | +			if (ret) | ||||||
| +				return 0; | +				goto out; | ||||||
| + | + | ||||||
| +			img_total = data_size + (data - fit); | +			img_total = data_size + (data - fit); | ||||||
| + | + | ||||||
| @@ -114,6 +111,7 @@ | |||||||
| +		} | +		} | ||||||
| +	} | +	} | ||||||
| + | + | ||||||
|  | +out: | ||||||
| +	return max_size; | +	return max_size; | ||||||
| +} | +} | ||||||
| + | + | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user