Skip to contentSkip to conversation

NFC: fix resource leak when target index is invalid

PATCH Applied Pan Bian 2 participants 2 messages Jan 21, 2021 – Jan 23, 2021

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 NFC: fix resource leak when target index is invalid

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")
---
 net/nfc/rawsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/rawsock.c +1 -1
index 955c195ae14b..9c7eb8455ba8 100644
@@ -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);
Signature · 1 line
2.17.1
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 8 lines · On Thu, 21 Jan 2021 07:27:48 -0800 you wrote:

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")
---
 net/nfc/rawsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- NFC: fix resource leak when target index is invalid

    https://git.kernel.org/netdev/net/c/3a30537cee23

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html