Patch "nfc: virtual_ncidev: Add variable to check if ndev is running" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nfc: virtual_ncidev: Add variable to check if ndev is running

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfc-virtual_ncidev-add-variable-to-check-if-ndev-is-.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 098e83c907b3fc6348d20443751e63c3e1fb6935
Author: Nguyen Dinh Phi <phind.uet@xxxxxxxxx>
Date:   Tue Nov 21 15:53:57 2023 +0800

    nfc: virtual_ncidev: Add variable to check if ndev is running
    
    [ Upstream commit 84d2db91f14a32dc856a5972e3f0907089093c7a ]
    
    syzbot reported an memory leak that happens when an skb is add to
    send_buff after virtual nci closed.
    This patch adds a variable to track if the ndev is running before
    handling new skb in send function.
    
    Signed-off-by: Nguyen Dinh Phi <phind.uet@xxxxxxxxx>
    Reported-by: syzbot+6eb09d75211863f15e3e@xxxxxxxxxxxxxxxxxxxxxxxxx
    Closes: https://lore.kernel.org/lkml/00000000000075472b06007df4fb@xxxxxxxxxx
    Reviewed-by: Bongsu Jeon
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c
index b027be0b0b6ff..590b038e449e5 100644
--- a/drivers/nfc/virtual_ncidev.c
+++ b/drivers/nfc/virtual_ncidev.c
@@ -26,10 +26,14 @@ struct virtual_nci_dev {
 	struct mutex mtx;
 	struct sk_buff *send_buff;
 	struct wait_queue_head wq;
+	bool running;
 };
 
 static int virtual_nci_open(struct nci_dev *ndev)
 {
+	struct virtual_nci_dev *vdev = nci_get_drvdata(ndev);
+
+	vdev->running = true;
 	return 0;
 }
 
@@ -40,6 +44,7 @@ static int virtual_nci_close(struct nci_dev *ndev)
 	mutex_lock(&vdev->mtx);
 	kfree_skb(vdev->send_buff);
 	vdev->send_buff = NULL;
+	vdev->running = false;
 	mutex_unlock(&vdev->mtx);
 
 	return 0;
@@ -50,7 +55,7 @@ static int virtual_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
 	struct virtual_nci_dev *vdev = nci_get_drvdata(ndev);
 
 	mutex_lock(&vdev->mtx);
-	if (vdev->send_buff) {
+	if (vdev->send_buff || !vdev->running) {
 		mutex_unlock(&vdev->mtx);
 		kfree_skb(skb);
 		return -1;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux