浏览代码

Merge tag 'fixes-for-v4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v4.12-rc5

Alan Stern fixed a GPF in gadgetfs found by the kernel fuzzying project

composite.c learned that if it deactivates a function during bind, it
must reactivate it during unbind.
Greg Kroah-Hartman 8 年之前
父节点
当前提交
8ada5f3ae9
共有 2 个文件被更改,包括 8 次插入7 次删除
  1. 5 6
      drivers/usb/gadget/composite.c
  2. 3 1
      drivers/usb/gadget/legacy/inode.c

+ 5 - 6
drivers/usb/gadget/composite.c

@@ -315,6 +315,9 @@ void usb_remove_function(struct usb_configuration *c, struct usb_function *f)
 	list_del(&f->list);
 	list_del(&f->list);
 	if (f->unbind)
 	if (f->unbind)
 		f->unbind(c, f);
 		f->unbind(c, f);
+
+	if (f->bind_deactivated)
+		usb_function_activate(f);
 }
 }
 EXPORT_SYMBOL_GPL(usb_remove_function);
 EXPORT_SYMBOL_GPL(usb_remove_function);
 
 
@@ -956,12 +959,8 @@ static void remove_config(struct usb_composite_dev *cdev,
 
 
 		f = list_first_entry(&config->functions,
 		f = list_first_entry(&config->functions,
 				struct usb_function, list);
 				struct usb_function, list);
-		list_del(&f->list);
-		if (f->unbind) {
-			DBG(cdev, "unbind function '%s'/%p\n", f->name, f);
-			f->unbind(config, f);
-			/* may free memory for "f" */
-		}
+
+		usb_remove_function(config, f);
 	}
 	}
 	list_del(&config->list);
 	list_del(&config->list);
 	if (config->unbind) {
 	if (config->unbind) {

+ 3 - 1
drivers/usb/gadget/legacy/inode.c

@@ -1183,8 +1183,10 @@ dev_release (struct inode *inode, struct file *fd)
 
 
 	/* closing ep0 === shutdown all */
 	/* closing ep0 === shutdown all */
 
 
-	if (dev->gadget_registered)
+	if (dev->gadget_registered) {
 		usb_gadget_unregister_driver (&gadgetfs_driver);
 		usb_gadget_unregister_driver (&gadgetfs_driver);
+		dev->gadget_registered = false;
+	}
 
 
 	/* at this point "good" hardware has disconnected the
 	/* at this point "good" hardware has disconnected the
 	 * device from USB; the host won't see it any more.
 	 * device from USB; the host won't see it any more.