tcm_usb_gadget: Fix enabled attribute failure
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 11 Dec 2015 15:06:15 +0000 (16:06 +0100)
committerNicholas Bellinger <nab@linux-iscsi.org>
Mon, 21 Dec 2015 03:40:21 +0000 (19:40 -0800)
Fix up tcm_usbg_tpg_store_enable() return value to propagate
usbg_attach() failure up to user-space if no HDC is found.

Reported-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/usb/gadget/legacy/tcm_usb_gadget.c

index e90d3c917e0b35d3aa13afc492e7b7fcc9bf2f14..65e49504d1ac717742f44ff2dcf493f5693a7347 100644 (file)
@@ -1505,10 +1505,14 @@ static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
        if (op > 1)
                return -EINVAL;
 
-       if (op && tpg->gadget_connect)
+       if (op && tpg->gadget_connect) {
+               ret = -EINVAL;
                goto out;
-       if (!op && !tpg->gadget_connect)
+       }
+       if (!op && !tpg->gadget_connect) {
+               ret = -EINVAL;
                goto out;
+       }
 
        if (op) {
                ret = usbg_attach(tpg);
@@ -1518,8 +1522,10 @@ static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
                usbg_detach(tpg);
        }
        tpg->gadget_connect = op;
-out:
+
        return count;
+out:
+       return ret;
 }
 
 static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page)