From: Qingfang Deng <qingfang.deng@linux.dev>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Qingfang Deng <qingfang.deng@linux.dev>,
Simon Horman <horms@kernel.org>, Kees Cook <kees@kernel.org>,
Taegu Ha <hataegu0826@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-ppp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/3] ppp: use file.dead to check channel unregistration
Date: Thu, 30 Apr 2026 17:05:21 +0800 [thread overview]
Message-ID: <20260430090532.244758-1-qingfang.deng@linux.dev> (raw)
Currently, ppp_generic checks if pch->chan is NULL to determine if a
channel is being unregistered. However, struct ppp_file already has a
'dead' flag for this purpose, which is used by ppp units and other
parts of the driver.
Switch all pch->chan NULL checks to pch->file.dead checks. In
ppp_unregister_channel, move the setting of pch->file.dead inside the
locked section to ensure atomicity and remove the now redundant
pch->chan = NULL assignment.
This is a preparation to eventually unify 'struct ppp_channel' and
'struct channel' into a single struct.
Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
---
drivers/net/ppp/ppp_generic.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 57c68efa5ff8..aef42a69b63c 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -790,7 +790,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
down_read(&pch->chan_sem);
chan = pch->chan;
err = -ENOTTY;
- if (chan && chan->ops->ioctl)
+ if (!pch->file.dead && chan->ops->ioctl)
err = chan->ops->ioctl(chan, cmd, arg);
up_read(&pch->chan_sem);
}
@@ -2167,7 +2167,7 @@ static void __ppp_channel_push(struct channel *pch, struct ppp *ppp)
struct sk_buff *skb;
spin_lock(&pch->downl);
- if (pch->chan) {
+ if (!pch->file.dead) {
while (!skb_queue_empty(&pch->file.xq)) {
skb = skb_dequeue(&pch->file.xq);
if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
@@ -2288,7 +2288,7 @@ static bool ppp_channel_bridge_input(struct channel *pch, struct sk_buff *skb)
goto out_rcu;
spin_lock_bh(&pchb->downl);
- if (!pchb->chan) {
+ if (pchb->file.dead) {
/* channel got unregistered */
kfree_skb(skb);
goto outl;
@@ -3002,7 +3002,7 @@ ppp_unregister_channel(struct ppp_channel *chan)
ppp_disconnect_channel(pch);
down_write(&pch->chan_sem);
spin_lock_bh(&pch->downl);
- pch->chan = NULL;
+ pch->file.dead = 1;
spin_unlock_bh(&pch->downl);
up_write(&pch->chan_sem);
@@ -3013,7 +3013,6 @@ ppp_unregister_channel(struct ppp_channel *chan)
ppp_unbridge_channels(pch);
- pch->file.dead = 1;
wake_up_interruptible(&pch->file.rwait);
ppp_release_channel(pch);
@@ -3505,7 +3504,7 @@ ppp_connect_channel(struct channel *pch, int unit)
ppp_lock(ppp);
spin_lock_bh(&pch->downl);
- if (!pch->chan) {
+ if (pch->file.dead) {
/* Don't connect unregistered channels */
spin_unlock_bh(&pch->downl);
ppp_unlock(ppp);
--
2.43.0
next reply other threads:[~2026-04-30 9:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 9:05 Qingfang Deng [this message]
2026-04-30 9:05 ` [PATCH net-next 2/3] ppp: unify two channel structs Qingfang Deng
2026-05-05 11:16 ` Paolo Abeni
2026-05-07 5:53 ` Qingfang Deng
2026-05-07 7:32 ` Paolo Abeni
2026-05-07 7:40 ` Sebastian Andrzej Siewior
2026-05-07 8:33 ` Qingfang Deng
2026-05-07 8:46 ` Sebastian Andrzej Siewior
2026-05-07 8:59 ` Qingfang Deng
2026-04-30 9:05 ` [PATCH net-next 3/3] docs: update ppp_generic.rst for API changes Qingfang Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260430090532.244758-1-qingfang.deng@linux.dev \
--to=qingfang.deng@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hataegu0826@gmail.com \
--cc=horms@kernel.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ppp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.