Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 539a06ba authored by Sabrina Dubroca's avatar Sabrina Dubroca Committed by David S. Miller
Browse files

tcp: ulp: avoid module refcnt leak in tcp_set_ulp



__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: 734942cc ("tcp: ULP infrastructure")
Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bae514a6
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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;
}