mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH] fastboot: handle error from file_list_parse()
Date: Wed, 21 Jul 2021 10:03:36 +0200
Message-ID: <577c9a3b-ccf2-f52a-03cd-311bd95e28fb@pengutronix.de> (raw)
In-Reply-To: <20210721075051.393141-1-r.czerwinski@pengutronix.de>

Hello Rouven,

On 21.07.21 09:50, Rouven Czerwinski wrote:
> In case an invalid file list is passed to file_list_parse(), it will
> return an error, i.e. by passing "/dev/mmc1(emmc) /dev/mmc1.1(root)",
> the error here being that the entries are not comma separated and
> file_list_parse will try to parse ' ' as a flag. The fastboot code
> didn't handle this, leading to the following error:
> 
>   ERROR: file_list: Unknown flag ' '
>   ERROR: file_list: parse error
>   unable to handle paging request at address 0xfffffff2
>   pc : [<8fe26a20>]    lr : [<8fe0f965>]
>   sp : 8ffeff50  ip : 8ffef714  fp : 00079bda
>   r10: 001b9ff8  r9 : 8fea7eec  r8 : 00000001
>   r7 : 00000000  r6 : 00000001  r5 : 00000000  r4 : 8813eab0
>   r3 : ffffffea  r2 : 00020000  r1 : 00000001  r0 : 8813eab0
>   Flags: nzCv  IRQs off  FIQs off  Mode SVC_32
>   WARNING: [<8fe26a20>] (usb_multi_count_functions+0xc/0x2a) from [<8fe0f965>] (usbgadget_register+0x79/0xf4)
>   WARNING: [<8fe0f965>] (usbgadget_register+0x79/0xf4) from [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c)
>   WARNING: [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) from [<8fe4d437>] (param_int_set+0x4b/0xb0)
>   WARNING: [<8fe4d437>] (param_int_set+0x4b/0xb0) from [<8fe4d899>] (dev_set_param+0x4d/0x64)
>   WARNING: [<8fe4d899>] (dev_set_param+0x4d/0x64) from [<8fe066f1>] (globalvar_add_bool+0x49/0x54)
>   WARNING: [<8fe066f1>] (globalvar_add_bool+0x49/0x54) from [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24)
>   WARNING: [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) from [<8fe01081>] (start_barebox+0x35/0x6c)
>   WARNING: [<8fe01081>] (start_barebox+0x35/0x6c) from [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164)
>   WARNING: [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) from [<8fe00005>] (__bare_init_start+0x1/0xc)
> 
>   WARNING: [<8fe64e3d>] (unwind_backtrace+0x1/0x78) from [<8fe01385>] (panic+0x1d/0x34)
>   WARNING: [<8fe01385>] (panic+0x1d/0x34) from [<8fe62723>] (do_exception+0xf/0x14)
>   WARNING: [<8fe62723>] (do_exception+0xf/0x14) from [<8fe62791>] (do_data_abort+0x21/0x34)
>   WARNING: [<8fe62791>] (do_data_abort+0x21/0x34) from [<8fe624d4>] (do_abort_6+0x48/0x54)
> 
> Add the proper error handling and notify the user with a proper error message.

get_dfu_function() suffers from the same issue. There is already a parse function in
common/usbgadget.c that warns and returns NULL. Could you move that somewhere
central and use it for both fastboot and dfu?

Thanks,
Ahmad 

> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  common/fastboot.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/common/fastboot.c b/common/fastboot.c
> index 75f6691b08..d53a1cd228 100644
> --- a/common/fastboot.c
> +++ b/common/fastboot.c
> @@ -918,8 +918,14 @@ bool get_fastboot_bbu(void)
>  
>  struct file_list *get_fastboot_partitions(void)
>  {
> -	if (fastboot_partitions && *fastboot_partitions)
> -		return file_list_parse(fastboot_partitions);
> +	struct file_list *list;
> +	if (fastboot_partitions && *fastboot_partitions) {
> +		list = file_list_parse(fastboot_partitions);
> +		if (IS_ERR(list)) {
> +			pr_err("parsing failure: '%s', returning NULL\n", fastboot_partitions);
> +			return NULL;
> +		}
> +	}
>  	if (!system_partitions_empty())
>  		return system_partitions_get();
>  	return NULL;
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-07-21  8:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  7:50 Rouven Czerwinski
2021-07-21  8:03 ` Ahmad Fatoum [this message]
2021-07-21  8:41   ` Rouven Czerwinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=577c9a3b-ccf2-f52a-03cd-311bd95e28fb@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git