Skip to content

Commit 0ad6bde

Browse files
f0rm2l1ndavem330
authored andcommitted
nfc/nci: fix race with opening and closing
Previously we leverage NCI_UNREG and the lock inside nci_close_device to prevent the race condition between opening a device and closing a device. However, it still has problem because a failed opening command will erase the NCI_UNREG flag and allow another opening command to bypass the status checking. This fix corrects that by making sure the NCI_UNREG is held. Reported-by: [email protected] Fixes: 48b71a9 ("NFC: add NCI_UNREG flag to eliminate the race") Signed-off-by: Lin Ma <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 24deec6 commit 0ad6bde

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/nfc/nci/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static int nci_open_device(struct nci_dev *ndev)
542542
skb_queue_purge(&ndev->tx_q);
543543

544544
ndev->ops->close(ndev);
545-
ndev->flags = 0;
545+
ndev->flags &= BIT(NCI_UNREG);
546546
}
547547

548548
done:

0 commit comments

Comments
 (0)