Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ppp: remove pch->chan NULL checks from tx path

Now that ppp_disconnect_channel() is called before pch->chan is set to
NULL, a channel from ppp->channels list on the transmit path is
guaranteed to have non-NULL pch->chan.

Remove the pch->chan NULL checks from ppp_push(), ppp_mp_explode(), and
ppp_fill_forward_path(), where a channel is obtained from the list.
Remove the corresponding WRITE/READ_ONCE annotations as they no longer
race.

Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Link: https://patch.msgid.link/20260312093732.277254-2-dqfext@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Qingfang Deng and committed by
Paolo Abeni
febe8012 6a196e83

+20 -46
+20 -46
drivers/net/ppp/ppp_generic.c
··· 1602 1602 if (!pch) 1603 1603 return -ENODEV; 1604 1604 1605 - chan = READ_ONCE(pch->chan); 1606 - if (!chan) 1607 - return -ENODEV; 1608 - 1605 + chan = pch->chan; 1609 1606 if (!chan->ops->fill_forward_path) 1610 1607 return -EOPNOTSUPP; 1611 1608 ··· 1925 1928 1926 1929 spin_lock(&pch->downl); 1927 1930 chan = pch->chan; 1928 - if (unlikely(!chan || (!chan->direct_xmit && skb_linearize(skb)))) { 1929 - /* channel got unregistered, or it requires a linear 1930 - * skb but linearization failed 1931 + if (unlikely(!chan->direct_xmit && skb_linearize(skb))) { 1932 + /* channel requires a linear skb but linearization 1933 + * failed 1931 1934 */ 1932 1935 kfree_skb(skb); 1933 1936 ret = 1; ··· 1988 1991 hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN; 1989 1992 i = 0; 1990 1993 list_for_each_entry(pch, &ppp->channels, clist) { 1991 - if (pch->chan) { 1992 - pch->avail = 1; 1993 - navail++; 1994 - pch->speed = pch->chan->speed; 1995 - } else { 1996 - pch->avail = 0; 1997 - } 1998 - if (pch->avail) { 1999 - if (skb_queue_empty(&pch->file.xq) || 2000 - !pch->had_frag) { 2001 - if (pch->speed == 0) 2002 - nzero++; 2003 - else 2004 - totspeed += pch->speed; 1994 + pch->avail = 1; 1995 + navail++; 1996 + pch->speed = pch->chan->speed; 2005 1997 2006 - pch->avail = 2; 2007 - ++nfree; 2008 - ++totfree; 2009 - } 2010 - if (!pch->had_frag && i < ppp->nxchan) 2011 - ppp->nxchan = i; 1998 + if (skb_queue_empty(&pch->file.xq) || !pch->had_frag) { 1999 + if (pch->speed == 0) 2000 + nzero++; 2001 + else 2002 + totspeed += pch->speed; 2003 + 2004 + pch->avail = 2; 2005 + ++nfree; 2006 + ++totfree; 2012 2007 } 2008 + if (!pch->had_frag && i < ppp->nxchan) 2009 + ppp->nxchan = i; 2010 + 2013 2011 ++i; 2014 2012 } 2015 2013 /* ··· 2063 2071 pch->avail = 1; 2064 2072 } 2065 2073 2066 - /* check the channel's mtu and whether it is still attached. */ 2067 2074 spin_lock(&pch->downl); 2068 - if (pch->chan == NULL) { 2069 - /* can't use this channel, it's being deregistered */ 2070 - if (pch->speed == 0) 2071 - nzero--; 2072 - else 2073 - totspeed -= pch->speed; 2074 - 2075 - spin_unlock(&pch->downl); 2076 - pch->avail = 0; 2077 - totlen = len; 2078 - totfree--; 2079 - nfree--; 2080 - if (--navail == 0) 2081 - break; 2082 - continue; 2083 - } 2084 - 2085 2075 /* 2086 2076 *if the channel speed is not set divide 2087 2077 *the packet evenly among the free channels; ··· 3009 3035 ppp_disconnect_channel(pch); 3010 3036 down_write(&pch->chan_sem); 3011 3037 spin_lock_bh(&pch->downl); 3012 - WRITE_ONCE(pch->chan, NULL); 3038 + pch->chan = NULL; 3013 3039 spin_unlock_bh(&pch->downl); 3014 3040 up_write(&pch->chan_sem); 3015 3041