]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: ath9k_htc: allocate tx_buf and buf together
authorRosen Penev <rosenp@gmail.com>
Thu, 21 May 2026 23:20:20 +0000 (16:20 -0700)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Sat, 6 Jun 2026 15:46:30 +0000 (08:46 -0700)
Use a flexible array member to combine allocations. No need to have them
separate as they are always together.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://patch.msgid.link/20260521232020.261405-1-rosenp@gmail.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath9k/hif_usb.c
drivers/net/wireless/ath/ath9k/hif_usb.h

index 7ad85a712757e727b086e37f5ee83caeba6adf41..515267f48d803e65fc1da432fe40efdcc6231bbc 100644 (file)
@@ -454,7 +454,6 @@ static void hif_usb_stop(void *hif_handle)
                usb_kill_urb(tx_buf->urb);
                list_del(&tx_buf->list);
                usb_free_urb(tx_buf->urb);
-               kfree(tx_buf->buf);
                kfree(tx_buf);
                spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
        }
@@ -811,7 +810,6 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
                                 &hif_dev->tx.tx_buf, list) {
                list_del(&tx_buf->list);
                usb_free_urb(tx_buf->urb);
-               kfree(tx_buf->buf);
                kfree(tx_buf);
        }
        spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
@@ -828,7 +826,6 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
                usb_kill_urb(tx_buf->urb);
                list_del(&tx_buf->list);
                usb_free_urb(tx_buf->urb);
-               kfree(tx_buf->buf);
                kfree(tx_buf);
                spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
        }
@@ -849,14 +846,10 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
        init_usb_anchor(&hif_dev->mgmt_submitted);
 
        for (i = 0; i < MAX_TX_URB_NUM; i++) {
-               tx_buf = kzalloc_obj(*tx_buf);
+               tx_buf = kzalloc_flex(*tx_buf, buf, MAX_TX_BUF_SIZE);
                if (!tx_buf)
                        goto err;
 
-               tx_buf->buf = kzalloc(MAX_TX_BUF_SIZE, GFP_KERNEL);
-               if (!tx_buf->buf)
-                       goto err;
-
                tx_buf->urb = usb_alloc_urb(0, GFP_KERNEL);
                if (!tx_buf->urb)
                        goto err;
@@ -871,10 +864,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
 
        return 0;
 err:
-       if (tx_buf) {
-               kfree(tx_buf->buf);
-               kfree(tx_buf);
-       }
+       kfree(tx_buf);
        ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
        return -ENOMEM;
 }
index c836bbe23b7a2bcacbcbd22923dbb9459f1619b1..dc0b0fa5c3257465b25ba00119d5982b121980d0 100644 (file)
@@ -77,13 +77,13 @@ extern int htc_use_dev_fw;
 #define HIF_USB_MAX_TXPIPES 4
 
 struct tx_buf {
-       u8 *buf;
        u16 len;
        u16 offset;
        struct urb *urb;
        struct sk_buff_head skb_queue;
        struct hif_device_usb *hif_dev;
        struct list_head list;
+       u8 buf[];
 };
 
 struct rx_buf {