summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-09-27 10:06:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-27 11:09:36 +0200
commit87f3efc26e3f4d8f171c56bdd819088f79e1110c (patch)
treef9d888aef173e90ba556efc4f0058710589089dc
parent9e6ddf343d61a6b2bb2a6dea8e4a34137a2978f9 (diff)
downloadbarebox-87f3efc26e3f4d8f171c56bdd819088f79e1110c.tar.gz
usbgadget: unregister when usb_composite_probe() fails
When usb_multi_register() returns an error it can't be called again as we do not unregister the driver properly. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/usb/gadget/multi.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 6385c16..6eeeb4e 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -234,6 +234,8 @@ static struct usb_composite_driver multi_driver = {
int usb_multi_register(struct f_multi_opts *opts)
{
+ int ret;
+
if (gadget_multi_opts) {
pr_err("USB multi gadget already registered\n");
return -EBUSY;
@@ -241,7 +243,13 @@ int usb_multi_register(struct f_multi_opts *opts)
gadget_multi_opts = opts;
- return usb_composite_probe(&multi_driver);
+ ret = usb_composite_probe(&multi_driver);
+ if (ret) {
+ usb_composite_unregister(&multi_driver);
+ gadget_multi_opts = NULL;
+ }
+
+ return ret;
}
void usb_multi_unregister(void)