Skip to content

Commit 0063fc3

Browse files
committed
Merge branch 'misc-bug-fixes-for-the-hso-driver'
Oliver Neukum says: ==================== misc bug fixes for the hso driver 1. Code reuse led to an unregistration of a net driver that has not been registered 2. The kernel complains generically if kmalloc with GFP_KERNEL fails 3. A race that can lead to an URB that is in use being reused or a use after free ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 8ed54f1 + abaf00f commit 0063fc3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/net/usb/hso.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,7 @@ static void hso_net_tx_timeout(struct net_device *net, unsigned int txqueue)
831831
dev_warn(&net->dev, "Tx timed out.\n");
832832

833833
/* Tear the waiting frame off the list */
834-
if (odev->mux_bulk_tx_urb &&
835-
(odev->mux_bulk_tx_urb->status == -EINPROGRESS))
834+
if (odev->mux_bulk_tx_urb)
836835
usb_unlink_urb(odev->mux_bulk_tx_urb);
837836

838837
/* Update statistics */
@@ -2357,7 +2356,7 @@ static int remove_net_device(struct hso_device *hso_dev)
23572356
}
23582357

23592358
/* Frees our network device */
2360-
static void hso_free_net_device(struct hso_device *hso_dev)
2359+
static void hso_free_net_device(struct hso_device *hso_dev, bool bailout)
23612360
{
23622361
int i;
23632362
struct hso_net *hso_net = dev2net(hso_dev);
@@ -2380,7 +2379,7 @@ static void hso_free_net_device(struct hso_device *hso_dev)
23802379
kfree(hso_net->mux_bulk_tx_buf);
23812380
hso_net->mux_bulk_tx_buf = NULL;
23822381

2383-
if (hso_net->net)
2382+
if (hso_net->net && !bailout)
23842383
free_netdev(hso_net->net);
23852384

23862385
kfree(hso_dev);
@@ -2465,10 +2464,9 @@ static void hso_create_rfkill(struct hso_device *hso_dev,
24652464
&interface_to_usbdev(interface)->dev,
24662465
RFKILL_TYPE_WWAN,
24672466
&hso_rfkill_ops, hso_dev);
2468-
if (!hso_net->rfkill) {
2469-
dev_err(dev, "%s - Out of memory\n", __func__);
2467+
if (!hso_net->rfkill)
24702468
return;
2471-
}
2469+
24722470
if (rfkill_register(hso_net->rfkill) < 0) {
24732471
rfkill_destroy(hso_net->rfkill);
24742472
hso_net->rfkill = NULL;
@@ -2556,7 +2554,7 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,
25562554

25572555
return hso_dev;
25582556
exit:
2559-
hso_free_net_device(hso_dev);
2557+
hso_free_net_device(hso_dev, true);
25602558
return NULL;
25612559
}
25622560

@@ -3133,7 +3131,7 @@ static void hso_free_interface(struct usb_interface *interface)
31333131
rfkill_unregister(rfk);
31343132
rfkill_destroy(rfk);
31353133
}
3136-
hso_free_net_device(network_table[i]);
3134+
hso_free_net_device(network_table[i], false);
31373135
}
31383136
}
31393137
}

0 commit comments

Comments
 (0)