Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 162c820e authored by Ilya Maximets's avatar Ilya Maximets Committed by Daniel Borkmann
Browse files

xdp: hold device for umem regardless of zero-copy mode



Device pointer stored in umem regardless of zero-copy mode,
so we heed to hold the device in all cases.

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>
parent 11aca65e
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -105,6 +105,9 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev,

	umem->dev = dev;
	umem->queue_id = queue_id;

	dev_hold(dev);

	if (force_copy)
		/* For copy-mode, we are done. */
		goto out_rtnl_unlock;
@@ -124,7 +127,6 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev,
		goto err_unreg_umem;
	rtnl_unlock();

	dev_hold(dev);
	umem->zc = true;
	return 0;

@@ -163,11 +165,10 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem)
	xdp_clear_umem_at_qid(umem->dev, umem->queue_id);
	rtnl_unlock();

	if (umem->zc) {
	dev_put(umem->dev);
	umem->dev = NULL;
	umem->zc = false;
}
}

static void xdp_umem_unpin_pages(struct xdp_umem *umem)
{