From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (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 89527311C32 for ; Thu, 16 Apr 2026 08:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776328034; cv=none; b=h9aD3b+tTFvY3YtIvYorjz0ciracWxppbVqGodq/XNLr8clz6TSfTmSVJn7v67/bowBK00mknciVj5WL5/yE8SCYLGzvQoIl103KRN8cTlY74Zs05inlB6D5D/tu5pFmz6xd0mwnrEY6HT3C2647htO6yCca5hL9Qddwn4s5AyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776328034; c=relaxed/simple; bh=HPHejJ+LnGwfAfrdx1fL/Y8Ru64+bxJnCtt0nJva9ro=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qMPPWmpDMO5uWmcMei/85HUluX/kwI87/oazQF/0NbzLXs27Y9Nx2Ap5t+RuMHl51PRESRRN1VvH1zZWz9DNWQCf9wrjUMDSctpqMAc9ozJAbMlLLSdI/v5oScQd3M15Aeq4dPX4iktEALoDZml6MniDKAbs8UaJGMDa8GIs6YM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QjhW5LGs; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="QjhW5LGs" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776328030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Eyo6E9moK+UoY1nhPnWmvg7SM04PixojRAeBdTB1HB8=; b=QjhW5LGsHEKlbRp2/QnwP3tUv8ZMmwMlp2epSZp+vJ8bFwAHASaQS7lG9yp6/0HMpsX72D EY1L5kdIXh7eiaVgib3wswPM+xjT9X2mji9HlXj/UvwblVATZDrhcO1TNH8H1M/ofu1Dhg 7FOA8k38sciUOlzvO3B1vqGAMRKhtRA= From: Qingfang Deng To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Qingfang Deng , Breno Leitao , Sebastian Andrzej Siewior , Kuniyuki Iwashima , Kees Cook , linux-ppp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Paul Mackerras , Jaco Kroon , James Carlson Subject: [RFC net-next 1/3] ppp: use file.dead to check channel unregistration Date: Thu, 16 Apr 2026 16:26:44 +0800 Message-ID: <20260416082656.86963-1-qingfang.deng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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 b0d3bc49c685..fd2889e374c9 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