From: Hangyu Hua <hbh25y@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>,
krzysztof.kozlowski@linaro.org, sameo@linux.intel.com,
christophe.ricard@gmail.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfc: st21nfca: fix possible double free in st21nfca_im_recv_dep_res_cb()
Date: Thu, 23 Jun 2022 18:47:19 +0800 [thread overview]
Message-ID: <31fa8ce4-a132-03c6-3272-6f8448270830@gmail.com> (raw)
In-Reply-To: <39279ba0ced207f484b664fe5364fa4ee6271cfb.camel@redhat.com>
On 2022/6/23 17:42, Paolo Abeni wrote:
> On Wed, 2022-06-22 at 14:51 +0800, Hangyu Hua wrote:
>> nfc_tm_data_received will free skb internally when it fails. There is no
>> need to free skb in st21nfca_im_recv_dep_res_cb again.
>>
>> Fix this by setting skb to NULL when nfc_tm_data_received fails.
>>
>> Fixes: 1892bf844ea0 ("NFC: st21nfca: Adding P2P support to st21nfca in Initiator & Target mode")
>> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
>> ---
>> drivers/nfc/st21nfca/dep.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c
>> index 1ec651e31064..07ac5688011c 100644
>> --- a/drivers/nfc/st21nfca/dep.c
>> +++ b/drivers/nfc/st21nfca/dep.c
>> @@ -594,7 +594,8 @@ static void st21nfca_im_recv_dep_res_cb(void *context, struct sk_buff *skb,
>> ST21NFCA_NFC_DEP_PFB_PNI(dep_res->pfb + 1);
>> size++;
>> skb_pull(skb, size);
>> - nfc_tm_data_received(info->hdev->ndev, skb);
>> + if (nfc_tm_data_received(info->hdev->ndev, skb))
>> + skb = NULL;
>
> Note that 'skb' not used (nor freed) by this function after this point:
> the next 'break' statement refears to the inner switch, and land to the
> execution flow to the 'return' statement a few lines below.
> kfree_skb(skb) is never reached.
>
> Paolo
>
My fault. I messed up two switch statements. I will be more careful next
time.
hangyu
prev parent reply other threads:[~2022-06-23 10:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 6:51 Hangyu Hua
2022-06-23 9:42 ` Paolo Abeni
2022-06-23 10:47 ` Hangyu Hua [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31fa8ce4-a132-03c6-3272-6f8448270830@gmail.com \
--to=hbh25y@gmail.com \
--cc=christophe.ricard@gmail.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®