[PATCH ath-next v4 3/8] wifi: ath9k_htc: refuse a command that fills whole USB packets

From: Nerijus Bendžiūnas

Date: Wed Sep 16 2026 - 14:39:23 EST


The firmware ends a command on the interrupt OUT endpoint only on a
short packet, so a command whose length is a multiple of the packet
size is never delivered and the device stops answering WMI. The
previous patch removes the one such command; nothing prevents the next.

Refuse such a command in hif_usb_send_regout(), where the packet size
is known, with a warning.

Assisted-by: LLM
Signed-off-by: Nerijus Bendžiūnas <nerijus.bendziunas@xxxxxxxxx>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index d3491ff08e6e..4b57cc2f3d6c 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -99,10 +99,17 @@ static void hif_usb_regout_cb(struct urb *urb)
static int hif_usb_send_regout(struct hif_device_usb *hif_dev,
struct sk_buff *skb)
{
+ u16 maxpacket = usb_maxpacket(hif_dev->udev,
+ usb_sndintpipe(hif_dev->udev,
+ USB_REG_OUT_PIPE));
struct urb *urb;
struct cmd_buf *cmd;
int ret = 0;

+ if (WARN_ONCE(maxpacket && skb->len % maxpacket == 0,
+ "%u-byte command fills whole USB packets\n", skb->len))
+ return -EMSGSIZE;
+
urb = usb_alloc_urb(0, GFP_KERNEL);
if (urb == NULL)
return -ENOMEM;
--
2.55.0