From 69b377b31be622762ebde5e5e63e8bed2e22bcea Mon Sep 17 00:00:00 2001 From: Olivier Sobrie Date: Fri, 30 Jan 2015 13:22:00 +0100 Subject: [PATCH] hso: move tty_unregister outside hso_serial_common_free() The function hso_serial_common_free() is called either by the cleanup method of the tty or by the usb disconnect method. In the former case, the usb_disconnect() has been already called and the sysfs group associated to the device has been removed. By calling tty_unregister directly from the usb_disconnect() method, we avoid a warning due to the removal of the sysfs group of the usb device. Example of warning: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 778 at fs/sysfs/group.c:225 sysfs_remove_group+0x50/0x94() sysfs group c0645a88 not found for kobject 'ttyHS5' Modules linked in: CPU: 0 PID: 778 Comm: kworker/0:3 Tainted: G W 3.18.0+ #105 Workqueue: events release_one_tty [] (unwind_backtrace) from [] (show_stack+0x14/0x1c) [] (show_stack) from [] (warn_slowpath_common+0x5c/0x7c) [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x30/0x40) [] (warn_slowpath_fmt) from [] (sysfs_remove_group+0x50/0x94) [] (sysfs_remove_group) from [] (device_del+0x30/0x190) [] (device_del) from [] (device_unregister+0xc/0x18) [] (device_unregister) from [] (device_destroy+0x30/0x3c) [] (device_destroy) from [] (tty_unregister_device+0x2c/0x5c) [] (tty_unregister_device) from [] (hso_serial_common_free+0x2c/0x88) [] (hso_serial_common_free) from [] (hso_serial_ref_free+0x3c/0xb8) [] (hso_serial_ref_free) from [] (release_one_tty+0x30/0x84) [] (release_one_tty) from [] (process_one_work+0x21c/0x3c8) [] (process_one_work) from [] (worker_thread+0x3d8/0x560) [] (worker_thread) from [] (kthread+0xc0/0xcc) [] (kthread) from [] (ret_from_fork+0x14/0x24) ---[ end trace cb88537fdc8fa208 ]--- Signed-off-by: Olivier Sobrie Signed-off-by: David S. Miller --- drivers/net/usb/hso.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 1e85ae76539e..5d885888658e 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2234,14 +2234,17 @@ static int hso_stop_serial_device(struct hso_device *hso_dev) return 0; } -static void hso_serial_common_free(struct hso_serial *serial) +static void hso_serial_tty_unregister(struct hso_serial *serial) { - int i; - if (serial->parent->dev) device_remove_file(serial->parent->dev, &dev_attr_hsotype); tty_unregister_device(tty_drv, serial->minor); +} + +static void hso_serial_common_free(struct hso_serial *serial) +{ + int i; for (i = 0; i < serial->num_rx_urbs; i++) { /* unlink and free RX URB */ @@ -2323,6 +2326,7 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, return 0; exit: + hso_serial_tty_unregister(serial); hso_serial_common_free(serial); return -1; } @@ -2683,6 +2687,7 @@ static struct hso_device *hso_create_bulk_serial_device( return hso_dev; exit2: + hso_serial_tty_unregister(serial); hso_serial_common_free(serial); exit: hso_free_tiomget(serial); @@ -3102,6 +3107,7 @@ static void hso_free_interface(struct usb_interface *interface) mutex_lock(&serial->parent->mutex); serial->parent->usb_gone = 1; mutex_unlock(&serial->parent->mutex); + hso_serial_tty_unregister(serial); kref_put(&serial_table[i]->ref, hso_serial_ref_free); } }