diff options
author | Pan Bian <bianpan2016@163.com> | 2021-01-21 07:27:48 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-02-03 23:16:17 +0100 |
commit | 074013e1d28d5e1158c7018730cd34570bc713c1 (patch) | |
tree | 8e96df6752450786044f1911cca370ce1a9a6884 /net | |
parent | cf682c5219ae01fba97dd06782dc49a6495f43d3 (diff) | |
download | linux-stable-074013e1d28d5e1158c7018730cd34570bc713c1.tar.gz linux-stable-074013e1d28d5e1158c7018730cd34570bc713c1.tar.bz2 linux-stable-074013e1d28d5e1158c7018730cd34570bc713c1.zip |
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.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 574af981806f..92a3cfae4de8 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -117,7 +117,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); |