file_list_parse() can fail. Print an error message in this case instead
of crashing.

Signed-off-by: Sascha Hauer <s.ha...@pengutronix.de>
---
 commands/usbgadget.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/commands/usbgadget.c b/commands/usbgadget.c
index ba09f97847..59359098ad 100644
--- a/commands/usbgadget.c
+++ b/commands/usbgadget.c
@@ -83,10 +83,14 @@ static int do_usbgadget(int argc, char *argv[])
 
        if (fastboot_opts) {
                opts->fastboot_opts.files = file_list_parse(fastboot_opts);
+               if (IS_ERR(opts->fastboot_opts.files))
+                       goto err_parse;
        }
 
        if (dfu_opts) {
                opts->dfu_opts.files = file_list_parse(dfu_opts);
+               if (IS_ERR(opts->dfu_opts.files))
+                       goto err_parse;
        }
 
        if (create_serial) {
@@ -98,6 +102,13 @@ static int do_usbgadget(int argc, char *argv[])
                usb_multi_opts_release(opts);
 
        return ret;
+
+err_parse:
+       printf("Cannot parse file list \"%s\": %s\n", fastboot_opts, 
strerrorp(opts->fastboot_opts.files));
+
+       free(opts);
+
+       return 1;
 }
 
 BAREBOX_CMD_HELP_START(usbgadget)
-- 
2.11.0


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

Reply via email to