lkml.org 
[lkml]   [2021]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 511/530] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req
    Date
    From: Lv Yunlong <lyl2019@mail.ustc.edu.cn>

    [ Upstream commit 75258586793efc521e5dd52a5bf6c7a4cf7002be ]

    In digital_tg_recv_dep_req, it calls nfc_tm_data_received(..,resp).
    If nfc_tm_data_received() failed, the callee will free the resp via
    kfree_skb() and return error. But in the exit branch, the resp
    will be freed again.

    My patch sets resp to NULL if nfc_tm_data_received() failed, to
    avoid the double free.

    Fixes: 1c7a4c24fbfd9 ("NFC Digital: Add target NFC-DEP support")
    Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    net/nfc/digital_dep.c | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
    index 5971fb6f51cc..dc21b4141b0a 100644
    --- a/net/nfc/digital_dep.c
    +++ b/net/nfc/digital_dep.c
    @@ -1273,6 +1273,8 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg,
    }

    rc = nfc_tm_data_received(ddev->nfc_dev, resp);
    + if (rc)
    + resp = NULL;

    exit:
    kfree_skb(ddev->chaining_skb);
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-05-12 19:01    [W:5.810 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site