Skip to content

Commit

Permalink
tcp: ulp: avoid module refcnt leak in tcp_set_ulp
Browse files Browse the repository at this point in the history
__tcp_ulp_find_autoload returns tcp_ulp_ops after taking a reference on
the module. Then, if ->init fails, tcp_set_ulp propagates the error but
nothing releases that reference.

Fixes: 734942c ("tcp: ULP infrastructure")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
qsn authored and davem330 committed Aug 15, 2017
1 parent bae514a commit 539a06b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/ipv4/tcp_ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ int tcp_set_ulp(struct sock *sk, const char *name)

ulp_ops = __tcp_ulp_find_autoload(name);
if (!ulp_ops)
err = -ENOENT;
else
err = ulp_ops->init(sk);
return -ENOENT;

if (err)
goto out;
err = ulp_ops->init(sk);
if (err) {
module_put(ulp_ops->owner);
return err;
}

icsk->icsk_ulp_ops = ulp_ops;
out:
return err;
return 0;
}

0 comments on commit 539a06b

Please sign in to comment.