Commit 3b7d2b31 authored by Jan Dumon's avatar Jan Dumon Committed by David S. Miller

hso: fix for crash when unplugging the device

Changed the order in which things are freed. This fixes an oops when
unplugging the device while network traffic is ongoing.
Signed-off-by: default avatarJan Dumon <j.dumon@option.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b6bc978b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Copyright (C) 2008 Option International * Copyright (C) 2008 Option International
* Filip Aben <f.aben@option.com> * Filip Aben <f.aben@option.com>
* Denis Joseph Barrow <d.barow@option.com> * Denis Joseph Barrow <d.barow@option.com>
* Jan Dumon <j.dumon@option.com>
* Copyright (C) 2007 Andrew Bird (Sphere Systems Ltd) * Copyright (C) 2007 Andrew Bird (Sphere Systems Ltd)
* <ajb@spheresystems.co.uk> * <ajb@spheresystems.co.uk>
* Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
...@@ -2417,20 +2418,22 @@ static void hso_free_net_device(struct hso_device *hso_dev) ...@@ -2417,20 +2418,22 @@ static void hso_free_net_device(struct hso_device *hso_dev)
if (!hso_net) if (!hso_net)
return; return;
remove_net_device(hso_net->parent);
if (hso_net->net) {
unregister_netdev(hso_net->net);
free_netdev(hso_net->net);
}
/* start freeing */ /* start freeing */
for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) {
usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]);
kfree(hso_net->mux_bulk_rx_buf_pool[i]); kfree(hso_net->mux_bulk_rx_buf_pool[i]);
hso_net->mux_bulk_rx_buf_pool[i] = NULL;
} }
usb_free_urb(hso_net->mux_bulk_tx_urb); usb_free_urb(hso_net->mux_bulk_tx_urb);
kfree(hso_net->mux_bulk_tx_buf); kfree(hso_net->mux_bulk_tx_buf);
hso_net->mux_bulk_tx_buf = NULL;
remove_net_device(hso_net->parent);
if (hso_net->net) {
unregister_netdev(hso_net->net);
free_netdev(hso_net->net);
}
kfree(hso_dev); kfree(hso_dev);
} }
...@@ -2620,12 +2623,12 @@ static void hso_free_tiomget(struct hso_serial *serial) ...@@ -2620,12 +2623,12 @@ static void hso_free_tiomget(struct hso_serial *serial)
{ {
struct hso_tiocmget *tiocmget = serial->tiocmget; struct hso_tiocmget *tiocmget = serial->tiocmget;
if (tiocmget) { if (tiocmget) {
kfree(tiocmget);
if (tiocmget->urb) { if (tiocmget->urb) {
usb_free_urb(tiocmget->urb); usb_free_urb(tiocmget->urb);
tiocmget->urb = NULL; tiocmget->urb = NULL;
} }
serial->tiocmget = NULL; serial->tiocmget = NULL;
kfree(tiocmget);
} }
} }
......
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