* [PATCH net] tcp: ulp: avoid module refcnt leak in tcp_set_ulp
@ 2017-08-14 16:04 Sabrina Dubroca
2017-08-15 5:17 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Sabrina Dubroca @ 2017-08-14 16:04 UTC (permalink / raw)
To: netdev
Cc: Sabrina Dubroca, Dave Watson, Boris Pismenny, Tom Herbert,
Hannes Frederic Sowa
__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: 734942cc4ea6 ("tcp: ULP infrastructure")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
Tom, the generalized ULP version has the same problem in ulp_set().
net/ipv4/tcp_ulp.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index 2417f55374c5..6bb9e14c710a 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -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;
}
--
2.14.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] tcp: ulp: avoid module refcnt leak in tcp_set_ulp
2017-08-14 16:04 [PATCH net] tcp: ulp: avoid module refcnt leak in tcp_set_ulp Sabrina Dubroca
@ 2017-08-15 5:17 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-08-15 5:17 UTC (permalink / raw)
To: sd; +Cc: netdev, davejwatson, borisp, tom, hannes
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Mon, 14 Aug 2017 18:04:24 +0200
> __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: 734942cc4ea6 ("tcp: ULP infrastructure")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-15 5:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 16:04 [PATCH net] tcp: ulp: avoid module refcnt leak in tcp_set_ulp Sabrina Dubroca
2017-08-15 5:17 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.