nfc: nfcmrvl: fix null pointer dereference in nfcmrvl_bulk_complete
PATCH 1/1 nfc: nfcmrvl: fix null pointer dereference in nfcmrvl_bulk_complete
A race condition in the current implementation can cause a null pointer dereference. When nfcmrvl_nci_register_dev() calls nci_register_device(), the NCI device is immediately exposed to userspace. If userspace brings up the device before probe() finishes assigning drv_data->priv, submitted bulk URBs can complete while priv is still NULL.
Additionally, nfcmrvl_bulk_complete() incorrectly checked NFCMRVL_NCI_RUNNING on drv_data->flags instead of drv_data->priv->flags.
Fix this by adding a NULL check and testing NFCMRVL_NCI_RUNNING on drv_data->priv->flags before processing the completed URB.
--- drivers/nfc/nfcmrvl/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/nfcmrvl/usb.c +1 -1
@@ -61,7 +61,7 @@ static void nfcmrvl_bulk_complete(struct urb *urb)dev_dbg (&drv_data->udev->dev,"urb %p status %d count %d\n" , urb, urb->status, urb->actual_length); -if (!test_bit (NFCMRVL_NCI_RUNNING , &drv_data->flags)) +if (!drv_data->priv || !test_bit (NFCMRVL_NCI_RUNNING , &drv_data->priv->flags))return ;if (!urb->status) {
Signature · 1 line
2.47.3
Quoted 26 lines · On Mon, 31 Aug 2026 10:41:10 +0000 Joshua Crofts <[email protected]>…
A race condition in the current implementation can cause a null pointer dereference. When
nfcmrvl_nci_register_dev()callsnci_register_device(), the NCI device is immediately exposed to userspace. If userspace brings up the device beforeprobe()finishes assigningdrv_data->priv, submitted bulk URBs can complete while priv is still NULL.Additionally,
nfcmrvl_bulk_complete()incorrectly checkedNFCMRVL_NCI_RUNNINGondrv_data->flagsinstead ofdrv_data->priv->flags.Fix this by adding a NULL check and testing
NFCMRVL_NCI_RUNNINGondrv_data->priv->flagsbefore processing the completed URB.Fixes f26e30cc6b50 ("NFC: nfcmrvl: Initial commit for Marvell NFC driver")Reported-by [email protected]Tested-by [email protected]Signed-off-by Joshua Crofts <[email protected]>--- drivers/nfc/nfcmrvl/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nfc/nfcmrvl/usb.c +0
-0
drivers/nfc/nfcmrvl/usb.c static void nfcmrvl_bulk_complete(struct urb *urb) · line 67
Quoted 8 lines
drivers/nfc/nfcmrvl/usb.c +1
-1@@ -61,7 +61,7 @@ static void nfcmrvl_bulk_complete(struct urb *urb)dev_dbg (&drv_data->udev->dev,"urb %p status %d count %d\n" , urb, urb->status, urb->actual_length); -if (!test_bit (NFCMRVL_NCI_RUNNING , &drv_data->flags)) +if (!drv_data->priv || !test_bit (NFCMRVL_NCI_RUNNING , &drv_data->priv->flags))return ;if (!urb->status) {
Hi David,
gentle ping on this patch.
Signature · 2 lines
Kind regards, Joshua Crofts