mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 14:41:27 +00:00
net: hso: add failure handler for add_net_device
If the network devices connected to the system beyond
HSO_MAX_NET_DEVICES. add_net_device() in hso_create_net_device()
will be failed for the network_table is full. It will lead to
business failure which rely on network_table, for example,
hso_suspend() and hso_resume(). It will also lead to memory leak
because resource release process can not search the hso_device
object from network_table in hso_free_interface().
Add failure handler for add_net_device() in hso_create_net_device()
to solve the above problems.
Fixes: 72dc1c096c
("HSO: add option hso driver")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b9edbfe1ad
commit
ecdc28defc
1 changed files with 8 additions and 3 deletions
|
@ -2535,13 +2535,17 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,
|
||||||
if (!hso_net->mux_bulk_tx_buf)
|
if (!hso_net->mux_bulk_tx_buf)
|
||||||
goto err_free_tx_urb;
|
goto err_free_tx_urb;
|
||||||
|
|
||||||
add_net_device(hso_dev);
|
result = add_net_device(hso_dev);
|
||||||
|
if (result) {
|
||||||
|
dev_err(&interface->dev, "Failed to add net device\n");
|
||||||
|
goto err_free_tx_buf;
|
||||||
|
}
|
||||||
|
|
||||||
/* registering our net device */
|
/* registering our net device */
|
||||||
result = register_netdev(net);
|
result = register_netdev(net);
|
||||||
if (result) {
|
if (result) {
|
||||||
dev_err(&interface->dev, "Failed to register device\n");
|
dev_err(&interface->dev, "Failed to register device\n");
|
||||||
goto err_free_tx_buf;
|
goto err_rmv_ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
hso_log_port(hso_dev);
|
hso_log_port(hso_dev);
|
||||||
|
@ -2550,8 +2554,9 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,
|
||||||
|
|
||||||
return hso_dev;
|
return hso_dev;
|
||||||
|
|
||||||
err_free_tx_buf:
|
err_rmv_ndev:
|
||||||
remove_net_device(hso_dev);
|
remove_net_device(hso_dev);
|
||||||
|
err_free_tx_buf:
|
||||||
kfree(hso_net->mux_bulk_tx_buf);
|
kfree(hso_net->mux_bulk_tx_buf);
|
||||||
err_free_tx_urb:
|
err_free_tx_urb:
|
||||||
usb_free_urb(hso_net->mux_bulk_tx_urb);
|
usb_free_urb(hso_net->mux_bulk_tx_urb);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue