[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211105133636.31282-1-cyeaa@connect.ust.hk>
Date: Fri, 5 Nov 2021 06:36:36 -0700
From: Chengfeng Ye <cyeaa@...nect.ust.hk>
To: krzysztof.kozlowski@...onical.com, davem@...emloft.net,
kuba@...nel.org, wengjianfeng@...ong.com, dan.carpenter@...cle.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Chengfeng Ye <cyeaa@...nect.ust.hk>
Subject: [PATCH v2] nfc: pn533: Fix double free when pn533_fill_fragment_skbs() fails
skb is already freed by dev_kfree_skb in pn533_fill_fragment_skbs,
but follow error handler branch when pn533_fill_fragment_skbs()
fails, skb is freed again, results in double free issue. Fix this
by not free skb in error path of pn533_fill_fragment_skbs.
Signed-off-by: Chengfeng Ye <cyeaa@...nect.ust.hk>
---
drivers/nfc/pn533/pn533.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 787bcbd290f7..a491db46e3bd 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2216,7 +2216,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
frag = pn533_alloc_skb(dev, frag_size);
if (!frag) {
skb_queue_purge(&dev->fragment_skb);
- break;
+ return -ENOMEM;
}
if (!dev->tgt_mode) {
@@ -2285,7 +2285,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
/* jumbo frame ? */
if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
rc = pn533_fill_fragment_skbs(dev, skb);
- if (rc <= 0)
+ if (rc < 0)
goto error;
skb = skb_dequeue(&dev->fragment_skb);
@@ -2353,7 +2353,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
/* let's split in multiple chunks if size's too big */
if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
rc = pn533_fill_fragment_skbs(dev, skb);
- if (rc <= 0)
+ if (rc < 0)
goto error;
/* get the first skb */
--
2.17.1
Powered by blists - more mailing lists