Skip to content

Commit

Permalink
sctp: change to hold sk after auth shkey is created successfully
Browse files Browse the repository at this point in the history
commit 25bff6d upstream.

Now in sctp_endpoint_init(), it holds the sk then creates auth
shkey. But when the creation fails, it doesn't release the sk,
which causes a sk defcnf leak,

Here to fix it by only holding the sk when auth shkey is created
successfully.

Fixes: a29a5bd ("[SCTP]: Implement SCTP-AUTH initializations.")
Reported-by: [email protected]
Reported-by: [email protected]
Signed-off-by: Xin Long <[email protected]>
Acked-by: Neil Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <[email protected]>
  • Loading branch information
lxin authored and bwhacks committed Oct 5, 2019
1 parent 2489c9a commit b4b1f8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/sctp/endpointola.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
/* Initialize the bind addr area */
sctp_bind_addr_init(&ep->base.bind_addr, 0);

/* Remember who we are attached to. */
ep->base.sk = sk;
sock_hold(ep->base.sk);

/* Create the lists of associations. */
INIT_LIST_HEAD(&ep->asocs);

Expand Down Expand Up @@ -165,6 +161,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
ep->auth_hmacs_list = auth_hmacs;
ep->auth_chunk_list = auth_chunks;

/* Remember who we are attached to. */
ep->base.sk = sk;
sock_hold(ep->base.sk);

return ep;

nomem_hmacs:
Expand Down

0 comments on commit b4b1f8e

Please sign in to comment.