Skip to content

Commit 59b20b1

Browse files
Huiwen Hekuba-moo
authored andcommitted
sctp: make sctp_transport_init() void
sctp_transport_init() is static and never returns NULL. It is only called by sctp_transport_new(), so change it to void and remove the redundant return value check. Signed-off-by: Huiwen He <hehuiwen@kylinos.cn> Acked-by: Xin Long <lucien.xin@gmail.com> Link: https://patch.msgid.link/20251103023619.1025622-1-hehuiwen@kylinos.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5556f23 commit 59b20b1

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

net/sctp/transport.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
/* 1st Level Abstractions. */
3838

3939
/* Initialize a new transport from provided memory. */
40-
static struct sctp_transport *sctp_transport_init(struct net *net,
41-
struct sctp_transport *peer,
42-
const union sctp_addr *addr,
43-
gfp_t gfp)
40+
static void sctp_transport_init(struct net *net,
41+
struct sctp_transport *peer,
42+
const union sctp_addr *addr,
43+
gfp_t gfp)
4444
{
4545
/* Copy in the address. */
4646
peer->af_specific = sctp_get_af_specific(addr->sa.sa_family);
@@ -83,8 +83,6 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
8383
get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce));
8484

8585
refcount_set(&peer->refcnt, 1);
86-
87-
return peer;
8886
}
8987

9088
/* Allocate and initialize a new transport. */
@@ -96,20 +94,13 @@ struct sctp_transport *sctp_transport_new(struct net *net,
9694

9795
transport = kzalloc(sizeof(*transport), gfp);
9896
if (!transport)
99-
goto fail;
97+
return NULL;
10098

101-
if (!sctp_transport_init(net, transport, addr, gfp))
102-
goto fail_init;
99+
sctp_transport_init(net, transport, addr, gfp);
103100

104101
SCTP_DBG_OBJCNT_INC(transport);
105102

106103
return transport;
107-
108-
fail_init:
109-
kfree(transport);
110-
111-
fail:
112-
return NULL;
113104
}
114105

115106
/* This transport is no longer needed. Free up if possible, or

0 commit comments

Comments
 (0)