sctp: Unwind address notifier registration on failure
Subsystems (3)
PATCH 1/1 sctp: Unwind address notifier registration on failure
sctp_v4_add_protocol() and sctp_v6_add_protocol() register their address notifiers before registering the SCTP protocol handlers. If protocol registration fails, the functions return without unregistering the notifiers.
Unregister the notifiers on the protocol registration failure paths. Also propagate notifier registration failures instead of ignoring them.
--- net/sctp/ipv6.c | 10 ++++++++-- net/sctp/protocol.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-)
net/sctp/ipv6.c +8 -2
@@ -1176,11 +1176,17 @@ void sctp_v6_protosw_exit(void)/* Register with inet6 layer. */ int sctp_v6_add_protocol (void ) { +int ret; +/* Register notifier for inet6 address additions/deletions. */ -register_inet6addr_notifier (&sctp_inet6addr_notifier); + ret =register_inet6addr_notifier (&sctp_inet6addr_notifier); +if (ret) +return ret; -if (inet6_add_protocol (&sctpv6_protocol,IPPROTO_SCTP ) <0 ) +if (inet6_add_protocol (&sctpv6_protocol,IPPROTO_SCTP ) <0 ) { +unregister_inet6addr_notifier (&sctp_inet6addr_notifier);return -EAGAIN ; + }return 0 ; }
net/sctp/protocol.c +8 -2
@@ -1263,12 +1263,18 @@ static void sctp_v4_protosw_exit(void)static int sctp_v4_add_protocol (void ) { +int ret; +/* Register notifier for inet address additions/deletions. */ -register_inetaddr_notifier (&sctp_inetaddr_notifier); + ret =register_inetaddr_notifier (&sctp_inetaddr_notifier); +if (ret) +return ret;/* Register SCTP with inet layer. */ -if (inet_add_protocol (&sctp_protocol,IPPROTO_SCTP ) <0 ) +if (inet_add_protocol (&sctp_protocol,IPPROTO_SCTP ) <0 ) { +unregister_inetaddr_notifier (&sctp_inetaddr_notifier);return -EAGAIN ; + }return 0 ; }
Signature · 1 line
2.43.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 8 Jun 2026 12:22:30 -0400 you wrote:
sctp_v4_add_protocol()andsctp_v6_add_protocol()register their address notifiers before registering the SCTP protocol handlers. If protocol registration fails, the functions return without unregistering the notifiers.Unregister the notifiers on the protocol registration failure paths. Also propagate notifier registration failures instead of ignoring them.
[...]
Here is the summary with links:
- [net,v1] sctp: Unwind address notifier registration on failure
https://git.kernel.org/netdev/net-next/c/c8459ee2fef5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html