Skip to content

Commit

Permalink
NFC: fix resource leak when target index is invalid
Browse files Browse the repository at this point in the history
Goto to the label put_dev instead of the label error to fix potential
resource leak on path that the target index is invalid.

Fixes: c4fbb65 ("NFC: The core part should generate the target index")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Link: https://lore.kernel.org/r/20210121152748.98409-1-bianpan2016@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Pan Bian authored and Jakub Kicinski committed Jan 23, 2021
1 parent d8f923c commit 3a30537
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/nfc/rawsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
if (addr->target_idx > dev->target_next_idx - 1 ||
addr->target_idx < dev->target_next_idx - dev->n_targets) {
rc = -EINVAL;
goto error;
goto put_dev;
}

rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
Expand Down

0 comments on commit 3a30537

Please sign in to comment.