Skip to content

Commit

Permalink
NFC: digital: fix possible memory leak in digital_in_send_sdd_req()
Browse files Browse the repository at this point in the history
'skb' is allocated in digital_in_send_sdd_req(), but not free when
digital_in_send_cmd() failed, which will cause memory leak. Fix it
by freeing 'skb' if digital_in_send_cmd() return failed.

Fixes: 2c66dae ("NFC Digital: Add NFC-A technology support")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ziyang Xuan authored and Jakub Kicinski committed Oct 14, 2021
1 parent 58e7dcc commit 291c932
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/nfc/digital_technology.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,12 @@ static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev,
skb_put_u8(skb, sel_cmd);
skb_put_u8(skb, DIGITAL_SDD_REQ_SEL_PAR);

return digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res,
target);
rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res,
target);
if (rc)
kfree_skb(skb);

return rc;
}

static void digital_in_recv_sens_res(struct nfc_digital_dev *ddev, void *arg,
Expand Down

0 comments on commit 291c932

Please sign in to comment.