mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Oleksij Rempel <ore@pengutronix.de>
Subject: [PATCH 1/4] usbgadget: autostart: Handle errors in file list gracefully
Date: Wed, 27 Sep 2017 11:12:42 +0200	[thread overview]
Message-ID: <20170927091245.9476-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170927091245.9476-1-s.hauer@pengutronix.de>

file_list_parse() can fail and returns an error pointer. Print
an error message when it fails and also set to NULL again so
that usb_multi_register() does not stumble upon the error pointer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/autostart.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c
index 465d8fd380..3fa43137fa 100644
--- a/drivers/usb/gadget/autostart.c
+++ b/drivers/usb/gadget/autostart.c
@@ -11,6 +11,8 @@
  * GNU General Public License for more details.
  *
  */
+#define pr_fmt(fmt) "usbgadget autostart: " fmt
+
 #include <common.h>
 #include <command.h>
 #include <errno.h>
@@ -42,8 +44,14 @@ static int usbgadget_autostart(void)
 	opts = xzalloc(sizeof(*opts));
 	opts->release = usb_multi_opts_release;
 
-	if (fastboot_function)
+	if (fastboot_function) {
 		opts->fastboot_opts.files = file_list_parse(fastboot_function);
+		if (IS_ERR(opts->fastboot_opts.files)) {
+			pr_err("Parsing file list \"%s\" failed: %s\n", fastboot_function,
+			       strerrorp(opts->fastboot_opts.files));
+			opts->fastboot_opts.files = NULL;
+		}
+	}
 
 	opts->create_acm = acm;
 
-- 
2.11.0


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

  reply	other threads:[~2017-09-27  9:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27  9:12 usbgadget fix some crashes Sascha Hauer
2017-09-27  9:12 ` Sascha Hauer [this message]
2017-09-29 13:02   ` [PATCH 1/4] usbgadget: autostart: Handle errors in file list gracefully Oleksij Rempel
2017-09-27  9:12 ` [PATCH 2/4] usbgadget: do not register when no functions present Sascha Hauer
2017-09-29 13:05   ` Oleksij Rempel
2017-09-27  9:12 ` [PATCH 3/4] usbgadget: only set to peripheral mode when error checking is done Sascha Hauer
2017-09-29 13:06   ` Oleksij Rempel
2017-09-27  9:12 ` [PATCH 4/4] usbgadget: unregister when usb_composite_probe() fails Sascha Hauer
2017-09-29 13:08   ` Oleksij Rempel

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=20170927091245.9476-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=ore@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox