Skip to content

Commit

Permalink
xdp: check device pointer before clearing
Browse files Browse the repository at this point in the history
We should not call 'ndo_bpf()' or 'dev_put()' with NULL argument.

Fixes: c9b47cc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
Ilya Maximets authored and Daniel Borkmann committed Jun 12, 2019
1 parent f12dd75 commit 01d76b5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions net/xdp/xdp_umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
struct netdev_bpf bpf;
int err;

if (!umem->dev)
return;

if (umem->zc) {
bpf.command = XDP_SETUP_XSK_UMEM;
bpf.xsk.umem = NULL;
Expand All @@ -156,11 +159,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
WARN(1, "failed to disable umem!\n");
}

if (umem->dev) {
rtnl_lock();
xdp_clear_umem_at_qid(umem->dev, umem->queue_id);
rtnl_unlock();
}
rtnl_lock();
xdp_clear_umem_at_qid(umem->dev, umem->queue_id);
rtnl_unlock();

if (umem->zc) {
dev_put(umem->dev);
Expand Down

0 comments on commit 01d76b5

Please sign in to comment.