From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hangyu Hua <hbh25y@gmail.com>,
Tung Nguyen <tung.q.nguyen@dektech.com.au>,
"David S . Miller" <davem@davemloft.net>,
Sasha Levin <sashal@kernel.org>,
jmaloy@redhat.com, ying.xue@windriver.com, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
tipc-discussion@lists.sourceforge.net
Subject: [PATCH AUTOSEL 4.9 4/5] net: tipc: fix possible refcount leak in tipc_sk_create()
Date: Wed, 6 Jul 2022 11:34:06 -0400 [thread overview]
Message-ID: <20220706153407.1598915-4-sashal@kernel.org> (raw)
In-Reply-To: <20220706153407.1598915-1-sashal@kernel.org>
From: Hangyu Hua <hbh25y@gmail.com>
[ Upstream commit 00aff3590fc0a73bddd3b743863c14e76fd35c0c ]
Free sk in case tipc_sk_insert() fails.
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Reviewed-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/tipc/socket.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9f39276e5d4e..1b3516368057 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -341,6 +341,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
sock->state = state;
sock_init_data(sock, sk);
if (tipc_sk_insert(tsk)) {
+ sk_free(sk);
pr_warn("Socket create failed; port number exhausted\n");
return -EINVAL;
}
--
2.35.1
next prev parent reply other threads:[~2022-07-06 15:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 15:34 [PATCH AUTOSEL 4.9 1/5] virtio_mmio: Add missing PM calls to freeze/restore Sasha Levin
2022-07-06 15:34 ` [PATCH AUTOSEL 4.9 2/5] virtio_mmio: Restore guest page size on resume Sasha Levin
2022-07-06 15:34 ` [PATCH AUTOSEL 4.9 3/5] cpufreq: pmac32-cpufreq: Fix refcount leak bug Sasha Levin
2022-07-06 15:34 ` Sasha Levin [this message]
2022-07-06 15:34 ` [PATCH AUTOSEL 4.9 5/5] NFC: nxp-nci: don't print header length mismatch on i2c error Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220706153407.1598915-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hbh25y@gmail.com \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@dektech.com.au \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox