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

r8169: use READ_ONCE in rtl_tx_slots_avail

tp->dirty_tx and tp->cur_tx may be changed by a racing rtl_tx() or
rtl8169_start_xmit(). Use READ_ONCE() to annotate the races and ensure
that the compiler doesn't use cached values.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/5676fee3-f6b4-84f2-eba5-c64949a371ad@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
95f3c545 2caf08e7

+2 -1
+2 -1
drivers/net/ethernet/realtek/r8169_main.c
··· 4144 4144 static bool rtl_tx_slots_avail(struct rtl8169_private *tp, 4145 4145 unsigned int nr_frags) 4146 4146 { 4147 - unsigned int slots_avail = tp->dirty_tx + NUM_TX_DESC - tp->cur_tx; 4147 + unsigned int slots_avail = READ_ONCE(tp->dirty_tx) + NUM_TX_DESC 4148 + - READ_ONCE(tp->cur_tx); 4148 4149 4149 4150 /* A skbuff with nr_frags needs nr_frags+1 entries in the tx queue */ 4150 4151 return slots_avail > nr_frags;