Commit 7b0a271d authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Felipe Balbi

usb: gadget: gadgetfs: unregister gadget only if it got successfully registered

Gadgetfs driver called usb_gadget_unregister_driver unconditionally, even
if it didn't register it earlier due to other failures. This patch fixes
this.
Reported-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Tested-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 31b994a4
......@@ -130,7 +130,8 @@ struct dev_data {
setup_can_stall : 1,
setup_out_ready : 1,
setup_out_error : 1,
setup_abort : 1;
setup_abort : 1,
gadget_registered : 1;
unsigned setup_wLength;
/* the rest is basically write-once */
......@@ -1179,6 +1180,7 @@ dev_release (struct inode *inode, struct file *fd)
/* closing ep0 === shutdown all */
if (dev->gadget_registered)
usb_gadget_unregister_driver (&gadgetfs_driver);
/* at this point "good" hardware has disconnected the
......@@ -1847,6 +1849,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
* kick in after the ep0 descriptor is closed.
*/
value = len;
dev->gadget_registered = true;
}
return value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment