summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2021-01-21 07:27:48 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-02-03 23:26:01 +0100
commitc929c76e98b0764a865aba1df635bc1cb1b8fc24 (patch)
tree887f300236dcecc335d131161a73e54cbaf68c3c /net
parentb2f4a59a22160df3c1a5b67a9a063f1dd1ece624 (diff)
NFC: fix resource leak when target index is invalid
commit 3a30537cee233fb7da302491b28c832247d89bbe upstream. 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: c4fbb6515a4d ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/rawsock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index b5c867fe3232..23d5e56306a4 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -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);