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 86BA33CAE8D; Wed, 30 Sep 2026 19:01:41 +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=1790794902; cv=none; b=SyM+C8YBKxyMo8HudEYI4+d2E8t7dzER5M1i+8f97lgNSLg5HRKGxruvy8YPEhY6TfnFsU8CoYCdJFxYGo4xh+VJ52kSeKxShPBvfuUi/QYyIoDKIje6gspmARMiwoOQk1CVbeVdhH6x4GeiEJ9TbO+02WCbMDZhyl3V1jUqIrY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790794902; c=relaxed/simple; bh=dIObZoJ5NnSRoQsrJhlaA5fqz4Bm6ENPEYEy09vWz/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KP4sKYToMc7ZajJeoCaVdOydcQ0nTTpMhb7rga0Txoaizf2Mw7lK05Lfh3gKmXsMZNZVn1ZdLTmoGt4UCJv+gnG3zCFuMsMMxM7Oku0D7q/IreUhNH76ux6hwm/mCd/AemKkoL17myVRRASO9zvhpSsVTHJIQcG0X9UtMVrquTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=16p6CvZI; 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="16p6CvZI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A95AB1F00898; Wed, 30 Sep 2026 19:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790794901; bh=t6cjBy27lhH/6ZwD1/eUTOJ4gTazo/BdcnoMq0Up9BA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=16p6CvZIsBN72Wvo+TjittZoL2mE++DrIC7G2LMIDBfTeijwI+YY0ahnFcCB8yiYO PTyjjVhrb+iSbsJBCGfMkWbKIq039NC/btNtsxvWpqfaAW8bE4IN0i1747qnIOqecc 20PAwWORPTObAkmA7m0z++oSUCWYDfqePvP5SnLY= 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 6.6 0328/1193] phonet: check register_netdevice_notifier() error in phonet_device_init() Date: Wed, 30 Sep 2026 17:16:52 +0200 Message-ID: <20260930152441.429089111@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@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.6-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 3f020c362d6cd..260131669ed73 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