[U-Boot] [PATCH] cmd: dfu: Add error handling for failed registration

Lukasz Majewski l.majewski at samsung.com
Mon Aug 8 14:24:53 CEST 2016


Hi Sanchayan,

> Without this, if g_dnl_register() fails, DFU code continues on
> blindly and crashes. This fix makes it simply print an error
> message instead.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan at gmail.com>
> ---
>  cmd/dfu.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/cmd/dfu.c b/cmd/dfu.c
> index d8aae26..e19d69c 100644
> --- a/cmd/dfu.c
> +++ b/cmd/dfu.c
> @@ -54,7 +54,12 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int
> argc, char * const argv[]) int controller_index =
> simple_strtoul(usb_controller, NULL, 0);
> board_usb_init(controller_index, USB_INIT_DEVICE);
> g_dnl_clear_detach();
> -	g_dnl_register("usb_dnl_dfu");
> +	ret = g_dnl_register("usb_dnl_dfu");
> +	if (ret) {
> +		error("g_dnl_register failed");
> +		return CMD_RET_FAILURE;
> +	}
> +
>  	while (1) {
>  		if (g_dnl_detach()) {
>  			/*

Thanks for spotting, indeed there wasn't return code checking.

Acked-by: Lukasz Majewski <l.majewski at samsung.com>

I will add this to u-boot-dfu tree.

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group


More information about the U-Boot mailing list