diff --git a/sys/contrib/dev/rtw88/debug.h b/sys/contrib/dev/rtw88/debug.h --- a/sys/contrib/dev/rtw88/debug.h +++ b/sys/contrib/dev/rtw88/debug.h @@ -27,6 +27,7 @@ RTW_DBG_SDIO = 0x00040000, #if defined(__FreeBSD__) + RTW_DBG_SKB_LEAK = 0x08000000, RTW_DBG_IO_RW = 0x10000000, #endif RTW_DBG_UNEXP = 0x80000000, diff --git a/sys/contrib/dev/rtw88/pci.c b/sys/contrib/dev/rtw88/pci.c --- a/sys/contrib/dev/rtw88/pci.c +++ b/sys/contrib/dev/rtw88/pci.c @@ -979,8 +979,18 @@ int ret; ret = rtw_pci_tx_write_data(rtwdev, pkt_info, skb, queue); +#if defined(__linux__) if (ret) return ret; +#elif defined(__FreeBSD__) + if (ret) { + rtw_dbg(rtwdev, RTW_DBG_SKB_LEAK, "%s: rtw_pci_tx_write_data " + "returned %d, skb %p (len %u) freed\n", + __func__, ret, skb, skb->len); + dev_kfree_skb_any(skb); + return ret; + } +#endif ring = &rtwpci->tx_rings[queue]; spin_lock_bh(&rtwpci->irq_lock);