Root Cause Analysis
The memory leak is caused by missing sk_buff cleanup on error paths in nfcmrvl_usb_nci_send() (drivers/nfc/nfcmrvl/usb.c).
Object Lifecycle and Broken Invariant
In the NCI core, nci_send_frame() (net/nfc/nci/core.c:1369-1386) transfers ownership of the struct sk_buff to ndev->ops->send(ndev, skb). Callers such as nci_cmd_work() (net/nfc/nci/core.c:1633) and nci_tx_work() (net/nfc/nci/core.c:1549) ignore the return value of nci_send_frame(), and nfcmrvl_nci_send() (drivers/nfc/nfcmrvl/main.c:48-68) sets skb->dev = (void *)ndev and delegates directly to priv->if_ops->nci_send(priv, skb). Consequently, the transport driver's nci_send implementation is responsible for freeing skb on both success and failure (as done in nfcmrvl_i2c_nci_send() in drivers/nfc/nfcmrvl/i2c.c:139-145 and other NCI drivers such as fdp_nci_send() and nxp_nci_send()).
In drivers/nfc/nfcmrvl/usb.c, nfcmrvl_usb_nci_send() (lines 219–264) normally relies on the URB completion callback nfcmrvl_tx_complete() (lines 146–163) to free skb via kfree_skb(skb) (with urb->context = skb). However, nfcmrvl_usb_nci_send() fails to free skb whenever nfcmrvl_tx_complete() is not reached:
- If
!drv_data->bulk_tx_ep (lines 227–228) or usb_alloc_urb() fails (lines 230–232), it returns -ENODEV / -ENOMEM without calling kfree_skb(skb).
- When
usb_submit_urb(urb, GFP_ATOMIC) fails (lines 250–257), nfcmrvl_tx_complete() is never invoked. The error handler only calls kfree(urb->setup_packet), usb_unanchor_urb(urb), and usb_free_urb(urb), leaving skb unfreed (and drv_data->tx_in_flight incremented by nfcmrvl_inc_tx() at line 240 without a matching decrement).
- Similarly, if an URB is anchored on
&drv_data->deferred while NFCMRVL_USB_SUSPENDING is set (lines 240–246) and later discarded in nfcmrvl_play_deferred() (lines 372–397) or unanchored via usb_scuttle_anchored_urbs(&drv_data->deferred) in nfcmrvl_usb_nci_close() (line 215) / nfcmrvl_resume() (line 430), urb->context (skb) is never freed.
How the Reproducer Triggers the Leak
syz_usb_connect attaches a virtual USB device matching nfcmrvl_table (0x1286:0x2046, interface class 0xff, subclass 4, protocol 1 in drivers/nfc/nfcmrvl/usb.c:15-18). Its bulk OUT endpoint (0x01) has wMaxPacketSize == 0. nfcmrvl_probe() (drivers/nfc/nfcmrvl/usb.c:285-330) only checks that bulk RX/TX endpoints exist via usb_find_common_endpoints(), so registration succeeds.
- Sending
NFC_CMD_DEV_UP invokes nfc_genl_dev_up() -> nfc_dev_up() -> nci_dev_up() -> nci_open_device() (net/nfc/nci/core.c:474-552), which opens the driver and calls __nci_request(ndev, nci_reset_req, ...).
nci_reset_req() calls nci_send_cmd() (net/nfc/nci/core.c:1390-1418), which allocates a struct sk_buff via nci_skb_alloc() -> alloc_skb() -> __alloc_skb() (net/core/skbuff.c:675-746) and writes the 4-byte NCI_OP_CORE_RESET_CMD (20 00 01 01 seen in the second kmemleak hex dump) into skb->head (allocated via kmalloc_reserve(), size 704).
- Note on the two kmemleak records: the first record (
0xffff88810de57c00, size 240, allocated via napi_skb_cache_get() during an earlier wg_peer_create() -> napi_get_frags_check()) is the struct sk_buff itself, which was placed into the per-CPU napi_alloc_cache and later popped by __alloc_skb() (napi_skb_cache_get(false) at net/core/skbuff.c:699). Its hex dump shows skb->dev at offset 16 (0xffff888126b92000, set to ndev in nfcmrvl_nci_send() at drivers/nfc/nfcmrvl/main.c:54) and skb->sk = NULL at offset 24 (skb_orphan() in nci_send_frame()). Because this sk_buff itself became unreferenced after ndev was freed on USB disconnect, kmemleak reported both the unreferenced struct sk_buff (with its original bulk-cache allocation stack) and its skb->head buffer (0xffff888106699b80).
nci_cmd_work() dequeues skb and calls nci_send_frame() -> nfcmrvl_nci_send() -> nfcmrvl_usb_nci_send().
usb_submit_urb() (drivers/usb/core/urb.c:444-452) sees usb_endpoint_maxp(&ep->desc) == 0 on bulk_tx_ep and immediately returns -EMSGSIZE. nfcmrvl_usb_nci_send() unanchors and frees urb without calling kfree_skb(skb), leaking both skb and skb->head.