Commit d5aa4751 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

USB: g_printer: fix bug in unregistration

This patch (as1441) fixes a bug in g_printer.  The gadget driver, char
device number, and class device should be unregistered in reverse
order of registration.  As it is now, when the module is unloaded the
class device gets unregistered first, causing a crash when the unbind
method tries to access it.

This fixes Bugzilla #25882.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
CC: Roland Kletzing <devzero@web.de>
CC: Craig W. Nadler <craig@nadler.us>
CC: <stable@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bbfba052
...@@ -1596,13 +1596,12 @@ cleanup(void) ...@@ -1596,13 +1596,12 @@ cleanup(void)
int status; int status;
mutex_lock(&usb_printer_gadget.lock_printer_io); mutex_lock(&usb_printer_gadget.lock_printer_io);
class_destroy(usb_gadget_class);
unregister_chrdev_region(g_printer_devno, 2);
status = usb_gadget_unregister_driver(&printer_driver); status = usb_gadget_unregister_driver(&printer_driver);
if (status) if (status)
ERROR(dev, "usb_gadget_unregister_driver %x\n", status); ERROR(dev, "usb_gadget_unregister_driver %x\n", status);
unregister_chrdev_region(g_printer_devno, 2);
class_destroy(usb_gadget_class);
mutex_unlock(&usb_printer_gadget.lock_printer_io); mutex_unlock(&usb_printer_gadget.lock_printer_io);
} }
module_exit(cleanup); module_exit(cleanup);
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