diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2020-02-06 14:01:05 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-02-07 11:33:01 +0100 |
commit | 184367dce4f744bde54377203305ccc8889aa79f (patch) | |
tree | c2d9b5c2ef577f04482af7065944b71f5ddc0fe0 /drivers/net/hyperv/netvsc_drv.c | |
parent | 6910fe95c61880e75b1c3a20eb13a6fd01ca501a (diff) | |
download | lwn-184367dce4f744bde54377203305ccc8889aa79f.tar.gz lwn-184367dce4f744bde54377203305ccc8889aa79f.zip |
hv_netvsc: Fix XDP refcnt for synthetic and VF NICs
The caller of XDP_SETUP_PROG has already incremented refcnt in
__bpf_prog_get(), so drivers should only increment refcnt by
num_queues - 1.
To fix the issue, update netvsc_xdp_set() to add the correct number
to refcnt.
Hold a refcnt in netvsc_xdp_set()’s other caller, netvsc_attach().
And, do the same in netvsc_vf_setxdp(). Otherwise, every time when VF is
removed and added from the host side, the refcnt will be decreased by one,
which may cause page fault when unloading xdp program.
Fixes: 351e1581395f ("hv_netvsc: Add XDP support")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv/netvsc_drv.c')
-rw-r--r-- | drivers/net/hyperv/netvsc_drv.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 8fc71bd49894..65e12cb07f45 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1059,9 +1059,12 @@ static int netvsc_attach(struct net_device *ndev, prog = dev_info->bprog; if (prog) { + bpf_prog_inc(prog); ret = netvsc_xdp_set(ndev, prog, NULL, nvdev); - if (ret) + if (ret) { + bpf_prog_put(prog); goto err1; + } } /* In any case device is now ready */ |