Skip to content

Commit 7fc5091

Browse files
gregkhLee Jones
authored and
Lee Jones
committed
Revert "ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb"
This reverts commit 90ecba9f1041f436ed2b35ba7a970c7cc5d0df23 which is commit 2bbcaaee1fcbd83272e29f31e2bb7e70d8c49e05 upstream. It is being reverted upstream, just hasn't made it there yet and is causing lots of problems. Reported-by: Hans de Goede <[email protected]> Cc: Qiujun Huang <[email protected]> Cc: Kalle Valo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Lee Jones <[email protected]> Change-Id: Ideb5fd63c056ab0ed3241dc4e377c1ec81c54871
1 parent 54f28b0 commit 7fc5091

File tree

2 files changed

+11
-42
lines changed

2 files changed

+11
-42
lines changed

drivers/net/wireless/ath/ath9k/hif_usb.c

+11-37
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
641641

642642
static void ath9k_hif_usb_rx_cb(struct urb *urb)
643643
{
644-
struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
645-
struct hif_device_usb *hif_dev = rx_buf->hif_dev;
646-
struct sk_buff *skb = rx_buf->skb;
644+
struct sk_buff *skb = (struct sk_buff *) urb->context;
645+
struct hif_device_usb *hif_dev =
646+
usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
647647
int ret;
648648

649649
if (!skb)
@@ -683,15 +683,14 @@ static void ath9k_hif_usb_rx_cb(struct urb *urb)
683683
return;
684684
free:
685685
kfree_skb(skb);
686-
kfree(rx_buf);
687686
}
688687

689688
static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
690689
{
691-
struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
692-
struct hif_device_usb *hif_dev = rx_buf->hif_dev;
693-
struct sk_buff *skb = rx_buf->skb;
690+
struct sk_buff *skb = (struct sk_buff *) urb->context;
694691
struct sk_buff *nskb;
692+
struct hif_device_usb *hif_dev =
693+
usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
695694
int ret;
696695

697696
if (!skb)
@@ -749,7 +748,6 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
749748
return;
750749
free:
751750
kfree_skb(skb);
752-
kfree(rx_buf);
753751
urb->context = NULL;
754752
}
755753

@@ -795,7 +793,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
795793
init_usb_anchor(&hif_dev->mgmt_submitted);
796794

797795
for (i = 0; i < MAX_TX_URB_NUM; i++) {
798-
tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL);
796+
tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
799797
if (!tx_buf)
800798
goto err;
801799

@@ -832,22 +830,15 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
832830

833831
static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
834832
{
835-
struct rx_buf *rx_buf = NULL;
836-
struct sk_buff *skb = NULL;
837833
struct urb *urb = NULL;
834+
struct sk_buff *skb = NULL;
838835
int i, ret;
839836

840837
init_usb_anchor(&hif_dev->rx_submitted);
841838
spin_lock_init(&hif_dev->rx_lock);
842839

843840
for (i = 0; i < MAX_RX_URB_NUM; i++) {
844841

845-
rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
846-
if (!rx_buf) {
847-
ret = -ENOMEM;
848-
goto err_rxb;
849-
}
850-
851842
/* Allocate URB */
852843
urb = usb_alloc_urb(0, GFP_KERNEL);
853844
if (urb == NULL) {
@@ -862,14 +853,11 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
862853
goto err_skb;
863854
}
864855

865-
rx_buf->hif_dev = hif_dev;
866-
rx_buf->skb = skb;
867-
868856
usb_fill_bulk_urb(urb, hif_dev->udev,
869857
usb_rcvbulkpipe(hif_dev->udev,
870858
USB_WLAN_RX_PIPE),
871859
skb->data, MAX_RX_BUF_SIZE,
872-
ath9k_hif_usb_rx_cb, rx_buf);
860+
ath9k_hif_usb_rx_cb, skb);
873861

874862
/* Anchor URB */
875863
usb_anchor_urb(urb, &hif_dev->rx_submitted);
@@ -895,8 +883,6 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
895883
err_skb:
896884
usb_free_urb(urb);
897885
err_urb:
898-
kfree(rx_buf);
899-
err_rxb:
900886
ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
901887
return ret;
902888
}
@@ -908,21 +894,14 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev)
908894

909895
static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
910896
{
911-
struct rx_buf *rx_buf = NULL;
912-
struct sk_buff *skb = NULL;
913897
struct urb *urb = NULL;
898+
struct sk_buff *skb = NULL;
914899
int i, ret;
915900

916901
init_usb_anchor(&hif_dev->reg_in_submitted);
917902

918903
for (i = 0; i < MAX_REG_IN_URB_NUM; i++) {
919904

920-
rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
921-
if (!rx_buf) {
922-
ret = -ENOMEM;
923-
goto err_rxb;
924-
}
925-
926905
/* Allocate URB */
927906
urb = usb_alloc_urb(0, GFP_KERNEL);
928907
if (urb == NULL) {
@@ -937,14 +916,11 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
937916
goto err_skb;
938917
}
939918

940-
rx_buf->hif_dev = hif_dev;
941-
rx_buf->skb = skb;
942-
943919
usb_fill_int_urb(urb, hif_dev->udev,
944920
usb_rcvintpipe(hif_dev->udev,
945921
USB_REG_IN_PIPE),
946922
skb->data, MAX_REG_IN_BUF_SIZE,
947-
ath9k_hif_usb_reg_in_cb, rx_buf, 1);
923+
ath9k_hif_usb_reg_in_cb, skb, 1);
948924

949925
/* Anchor URB */
950926
usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
@@ -970,8 +946,6 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
970946
err_skb:
971947
usb_free_urb(urb);
972948
err_urb:
973-
kfree(rx_buf);
974-
err_rxb:
975949
ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
976950
return ret;
977951
}

drivers/net/wireless/ath/ath9k/hif_usb.h

-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ struct tx_buf {
6666
struct list_head list;
6767
};
6868

69-
struct rx_buf {
70-
struct sk_buff *skb;
71-
struct hif_device_usb *hif_dev;
72-
};
73-
7469
#define HIF_USB_TX_STOP BIT(0)
7570
#define HIF_USB_TX_FLUSH BIT(1)
7671

0 commit comments

Comments
 (0)