[OpenWrt-Devel] [PATCH RFT] kernel: mtdsplit_uimage: debug buf/header sizes

John Crispin blogic at openwrt.org
Thu Feb 12 14:25:10 EST 2015


yep, fixes the problem. please push it :)

On 12/02/2015 12:47, Rafał Miłecki wrote:
> ---
> John can you give it a try, please?
> ---
>  .../generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c  | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> index 2bb5e9a..4abc4be 100644
> --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
> @@ -20,6 +20,8 @@
>  
>  #include "mtdsplit.h"
>  
> +static int first_try = 1;
> +
>  /*
>   * uimage_header itself is only 64B, but it may be prepended with another data.
>   * Currently the biggest size is for Edimax devices: 20B + 64B
> @@ -60,6 +62,8 @@ read_uimage_header(struct mtd_info *mtd, size_t offset, u_char *buf,
>  	size_t retlen;
>  	int ret;
>  
> +	if (first_try)
> +		pr_info("[%s] buf:%p header_len:%zu\n", __FUNCTION__, buf, header_len);
>  	ret = mtd_read(mtd, offset, header_len, &retlen, buf);
>  	if (ret) {
>  		pr_debug("read error in \"%s\"\n", mtd->name);
> @@ -106,11 +110,15 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
>  		ret = -ENOMEM;
>  		goto err_free_parts;
>  	}
> +	if (first_try)
> +		pr_info("[%s] buf:%p sizeof(*buf):%u\n", __FUNCTION__, buf, sizeof(*buf));
>  
>  	/* find uImage on erase block boundaries */
>  	for (offset = 0; offset < master->size; offset += master->erasesize) {
>  		struct uimage_header *header;
>  
> +		if (first_try)
> +			pr_info("[%s] sizeof(*header):%u\n", __FUNCTION__, sizeof(*header));
>  		uimage_size = 0;
>  
>  		ret = read_uimage_header(master, offset, buf, sizeof(*buf));
> @@ -308,8 +316,13 @@ static ssize_t uimage_find_edimax(u_char *buf, size_t len)
>  {
>  	struct uimage_header *header;
>  
> +	if (first_try)
> +		pr_info("[%s] buf:%p len:%zu FW_EDIMAX_OFFSET + sizeof(*header):%u\n", __FUNCTION__, buf, len, FW_EDIMAX_OFFSET + sizeof(*header));
> +
>  	if (len < FW_EDIMAX_OFFSET + sizeof(*header)) {
> -		pr_err("Buffer too small for checking Edimax header\n");
> +		if (first_try)
> +			pr_err("Buffer too small for checking Edimax header\n");
> +		first_try = 0;
>  		return -ENOSPC;
>  	}
>  
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list