diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 044d5c3a4d048272e075001e827f29f3696356fd..09b89adc81cd8af166a43bfbabe682caa39f9ec6 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -599,13 +599,18 @@ static u16 tun_automq_select_queue(struct tun_struct *tun, struct sk_buff *skb) static u16 tun_ebpf_select_queue(struct tun_struct *tun, struct sk_buff *skb) { struct tun_prog *prog; + u32 numqueues; u16 ret = 0; + numqueues = READ_ONCE(tun->numqueues); + if (!numqueues) + return 0; + prog = rcu_dereference(tun->steering_prog); if (prog) ret = bpf_prog_run_clear_cb(prog->prog, skb); - return ret % tun->numqueues; + return ret % numqueues; } static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,