Commit a5769fc5 authored by Ilya Maximets's avatar Ilya Maximets Committed by Greg Kroah-Hartman

xdp: check device pointer before clearing

[ Upstream commit 01d76b53 ]

We should not call 'ndo_bpf()' or 'dev_put()' with NULL argument.

Fixes: c9b47cc1 ("xsk: fix bug when trying to use both copy and zero-copy on one queue id")
Signed-off-by: default avatarIlya Maximets <i.maximets@samsung.com>
Acked-by: default avatarJonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5f546398
...@@ -143,6 +143,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem) ...@@ -143,6 +143,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
struct netdev_bpf bpf; struct netdev_bpf bpf;
int err; int err;
if (!umem->dev)
return;
if (umem->zc) { if (umem->zc) {
bpf.command = XDP_SETUP_XSK_UMEM; bpf.command = XDP_SETUP_XSK_UMEM;
bpf.xsk.umem = NULL; bpf.xsk.umem = NULL;
...@@ -156,11 +159,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem) ...@@ -156,11 +159,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
WARN(1, "failed to disable umem!\n"); WARN(1, "failed to disable umem!\n");
} }
if (umem->dev) { rtnl_lock();
rtnl_lock(); xdp_clear_umem_at_qid(umem->dev, umem->queue_id);
xdp_clear_umem_at_qid(umem->dev, umem->queue_id); rtnl_unlock();
rtnl_unlock();
}
if (umem->zc) { if (umem->zc) {
dev_put(umem->dev); dev_put(umem->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment