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 9D289371049; Wed, 30 Sep 2026 15:39:28 +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=1790782776; cv=none; b=FHuSixBOowf9mjj+CIC4lamFinVwCSGfd9Torx//urwCr5tImnH24guvKxZBIYfxiwdY/9WP+e18uzWMnyxp34n1GEaDlb+CBdc9UIqcBacvTK4FLNQ0iLCJB3myM8LFqLVxS1khJZ8vr2Aa/9luZfHrdFyNDi6FYDcgOnduJ9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782776; c=relaxed/simple; bh=PVwGKYIYT4k9mvCVQDv7eSfCdXOZswPzxhs1qoSMNrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q+D8RHGxs9JzqCfHPfZbd9O3gCi9JC3d2LupS6fYK+IDeEcgvRCfOqF+v3ZxLgnGcI/UTjVubefVdMHssGOQcZwj2tJD+8HodqtGeHehhDl1cj7OcdBwzZ5AWV1E7m3TrxUXAHFRPKdRpcPSBUenVRzpQZI2nOLVejPrURevu24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Saald3rK; 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="Saald3rK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3F651F000FF; Wed, 30 Sep 2026 15:39:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790782766; bh=FSJYKEKPSTYjdNHfEBFHhY4/fjucyYxxiBZKeoVWLPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Saald3rKedfNQ9NUV8PwG58wi7QVQtRt8bOLLFkIzWcnaNIqO8oBxOTWeh5OLpP9a 74236KrJYN+s7fOQrRr8r1mOvoIlZP5/N12A9kWb9Xy1H907QvOMURFl4ht2pDjljB zuWzos/+IhVfxQwsym9dLV0gUKMY1/ZZwFKF0lmo= 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 5.10 117/595] sctp: Unwind address notifier registration on failure Date: Wed, 30 Sep 2026 17:20:10 +0200 Message-ID: <20260930152350.254480880@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152347.700140858@linuxfoundation.org> References: <20260930152347.700140858@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 5.10-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 48bd3b52d56d0..d56e4bdaa9c10 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -1149,11 +1149,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 6e3d0872491a2..5305a5be74dee 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1178,12 +1178,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