Skip to content

Commit 1378008

Browse files
xiaosuogregkh
authored andcommitted
net: disable preemption before call smp_processor_id()
[ Upstream commit cece1945bffcf1a823cdfa36669beae118419351 ] Although netif_rx() isn't expected to be called in process context with preemption enabled, it'd better handle this case. And this is why get_cpu() is used in the non-RPS #ifdef branch. If tree RCU is selected, rcu_read_lock() won't disable preemption, so preempt_disable() should be called explictly. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 34793c3 commit 1378008

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

net/core/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,7 @@ int netif_rx(struct sk_buff *skb)
25042504
struct rps_dev_flow voidflow, *rflow = &voidflow;
25052505
int cpu;
25062506

2507+
preempt_disable();
25072508
rcu_read_lock();
25082509

25092510
cpu = get_rps_cpu(skb->dev, skb, &rflow);
@@ -2513,6 +2514,7 @@ int netif_rx(struct sk_buff *skb)
25132514
ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
25142515

25152516
rcu_read_unlock();
2517+
preempt_enable();
25162518
}
25172519
#else
25182520
{

0 commit comments

Comments
 (0)