Patch "nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()" has been added to the 4.9-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: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()

to the 4.9-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-nfcmrvl-fix-potential-memory-leak-in-nfcmrvl_i2c.patch
and it can be found in the queue-4.9 subdirectory.

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



commit f12b4e6b22c8bf4bcb1616a20a29a74cf450056a
Author: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
Date:   Thu Oct 27 22:03:32 2022 +0800

    nfc: nfcmrvl: Fix potential memory leak in nfcmrvl_i2c_nci_send()
    
    [ Upstream commit 93d904a734a74c54d945a9884b4962977f1176cd ]
    
    nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
    should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
    will only free skb when i2c_master_send() return >=0, which means skb
    will memleak when i2c_master_send() failed. Free skb no matter whether
    i2c_master_send() succeeds.
    
    Fixes: b5b3e23e4cac ("NFC: nfcmrvl: add i2c driver")
    Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nfc/nfcmrvl/i2c.c b/drivers/nfc/nfcmrvl/i2c.c
index bb546cabe809..91d7ef11aba3 100644
--- a/drivers/nfc/nfcmrvl/i2c.c
+++ b/drivers/nfc/nfcmrvl/i2c.c
@@ -151,10 +151,15 @@ static int nfcmrvl_i2c_nci_send(struct nfcmrvl_private *priv,
 			ret = -EREMOTEIO;
 		} else
 			ret = 0;
+	}
+
+	if (ret) {
 		kfree_skb(skb);
+		return ret;
 	}
 
-	return ret;
+	consume_skb(skb);
+	return 0;
 }
 
 static void nfcmrvl_i2c_nci_update_config(struct nfcmrvl_private *priv,



[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