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 5A2D41FDE31; Wed, 30 Sep 2026 15:39:58 +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=1790782802; cv=none; b=hfVw0qZLKu4ziCLbyw5uthtIi4W82hq40D8+drU0PuVUsL+ioq3WY5yj8DrNegPbvzPTZ7q9NhsQNHbWnlr0pddxiqsUrpSJmX3Ceag5pI6wIrYj8vnLaQ/nqW79XHQl1w/4tW3ZCvVX6jG9W6geU33gBGjVMK3q/35WgSaptQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782802; c=relaxed/simple; bh=Aep3AyEp2UYFPIYWtzWVAaM/7ufIBunjroHn6c3zb7g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eA+nHsvjFudPlBstwImtKX07GdHvRHaH6+pU0QbePrQXp5fsHH5zC8Ts9c5OXpYRNEVgvd7Ru+kmnzNhBORNS/eLFEW0q57C0G5BUuuCD4qv2veezOVyh7sYER2ES1T4YmNdyd31QUWQ1N6Xa3djdp15cGw8zXnvh1/eJ8Gyf2c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=09Md8wl8; 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="09Md8wl8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128361F00898; Wed, 30 Sep 2026 15:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790782797; bh=CYiBaUVWANdz+MeeJzFw/3vXqRXuCLMv6DWrEuONzjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=09Md8wl8PRmVaWN1+6+5VJmDfc4vZb6tvk9mDSGV7Af83MiwgPOM8LDHLntc5MZUN YsHowATwodsrVJMjcJfS8gHS/yrof7HTFE1A3/AGIyBxTK1N7kYQqYYdtJY2xDE9md PzSjAJVJyg3J7Cw+eK7AW2NLjJcAA+hd6wpaTNPg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Minhong He , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 174/595] phonet: check register_netdevice_notifier() error in phonet_device_init() Date: Wed, 30 Sep 2026 17:21:07 +0200 Message-ID: <20260930152351.483715262@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: Minhong He [ Upstream commit d1ff66b66151c14b084e88040512a064b1c1e493 ] phonet_device_init() registers a netdevice notifier before calling phonet_netlink_register(), but does not check whether notifier registration succeeded. On failure, netlink setup still proceeds and init may return success without the notifier in place. Also, the existing phonet_netlink_register() failure path called phonet_device_exit(), which runs rtnl_unregister_all() even though rtnl_register_many() already unwound any partial registration. Calling the full exit helper on a partial init is not correct. Check each registration error, including proc_create_net(), and unwind only the steps that have succeeded so far, in reverse order. Signed-off-by: Minhong He Link: https://patch.msgid.link/20260721093956.162617-1-heminhong@kylinos.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/phonet/pn_dev.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index 2c48dcf6a7400..50d85de598119 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c @@ -336,16 +336,34 @@ static struct pernet_operations phonet_net_ops = { /* Initialize Phonet devices list */ int __init phonet_device_init(void) { - int err = register_pernet_subsys(&phonet_net_ops); + int err; + + err = register_pernet_subsys(&phonet_net_ops); if (err) return err; - proc_create_net("pnresource", 0, init_net.proc_net, &pn_res_seq_ops, - sizeof(struct seq_net_private)); - register_netdevice_notifier(&phonet_device_notifier); + if (!proc_create_net("pnresource", 0, init_net.proc_net, + &pn_res_seq_ops, sizeof(struct seq_net_private))) { + err = -ENOMEM; + goto err_pernet; + } + + err = register_netdevice_notifier(&phonet_device_notifier); + if (err) + goto err_proc; + err = phonet_netlink_register(); if (err) - phonet_device_exit(); + goto err_notifier; + + return 0; + +err_notifier: + unregister_netdevice_notifier(&phonet_device_notifier); +err_proc: + remove_proc_entry("pnresource", init_net.proc_net); +err_pernet: + unregister_pernet_subsys(&phonet_net_ops); return err; } @@ -353,8 +371,8 @@ void phonet_device_exit(void) { rtnl_unregister_all(PF_PHONET); unregister_netdevice_notifier(&phonet_device_notifier); - unregister_pernet_subsys(&phonet_net_ops); remove_proc_entry("pnresource", init_net.proc_net); + unregister_pernet_subsys(&phonet_net_ops); } int phonet_route_add(struct net_device *dev, u8 daddr) -- 2.53.0