From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2FD75304D7; Thu, 17 Sep 2026 17:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664479; cv=none; b=s6bsypyT8Ss7SzkSwcou8qw7Z8l6RU8JpkpeystaVixS6YsCAfKUIYe+lrLY7/Ak9wqUrmjmjjf7Q4JcjZd4dmUulTrSmLEeeb2fRjAZyx6Ps7DfVmNgth1XQl4Ojuqs/8fc5t4pwbk1ReLkakHXFgW1wqTe9wMsOzmPQuPLWmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664479; c=relaxed/simple; bh=oTqusYCJVG/tHXid4Er/C5HWSCj2dAJXantr7ULzJw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBBBw+xXAObD/t+SyTTvCr117isCsfQrgeGWpe4UEVR/dwVEtlS8Vp//u12sulm4gmgHt/7KgO7ZoUskZKWBxF85yXVdS4EK1+Jgs6fRHAhJy2lcABmCz3jq94hiN9Nzgko3OmBDdscK2o9hrgfjSjCeUkGFY4osN3rHc+ocqH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nghbOVyk; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nghbOVyk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F64B1F00899; Thu, 17 Sep 2026 17:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789664477; bh=GQPMC8GqS/pCslqCeuxrgCSskfri5WDyfQSFimg5LvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nghbOVykdZpvsEApZzH3cDKjndFtlGLSWs5CELDq2iohi/gv9JLjgIRawnJbi9qJ0 H3FeSwA35OxRpuPMD0tF2DbyP+ACARcTrxRkqtXBB4yCaXdF/X1XK40fIKZfIOdDCm rgqQBJjDfCZmOSd3zH1NnW04dLn23U8oJxQPTNMQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuho Choi , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 0384/1250] sctp: Unwind address notifier registration on failure Date: Thu, 17 Sep 2026 16:02:59 +0100 Message-ID: <20260917151602.452966045@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuho Choi [ Upstream commit c8459ee2fef502d6ef6c063751c33d9ac7943eab ] 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. Signed-off-by: Yuho Choi Link: https://patch.msgid.link/20260608162230.46644-1-dbgh9129@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/ipv6.c | 10 ++++++++-- net/sctp/protocol.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 7434309785cc5..922b19982d4fe 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -1225,11 +1225,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; } diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 5718328cb8a79..c718dc066f3a9 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1297,12 +1297,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; } -- 2.53.0