提交 17864891 编写于 作者: M Marek Majtyka 提交者: Daniel Borkmann

xsk: Fix incorrect netdev reference count

Fix incorrect netdev reference count in xsk_bind operation. Incorrect
reference count of the device appears when a user calls bind with the
XDP_ZEROCOPY flag on an interface which does not support zero-copy.
In such a case, an error is returned but the reference count is not
decreased. This change fixes the fault, by decreasing the reference count
in case of such an error.

The problem being corrected appeared in '162c820e' for the first time,
and the code was moved to new file location over the time with commit
'c2d3d6a4'. This specific patch applies to all version starting
from 'c2d3d6a4'. The same solution should be applied but on different
file (net/xdp/xdp_umem.c) and function (xdp_umem_assign_dev) for versions
from '162c820e' to 'c2d3d6a4' excluded.

Fixes: 162c820e ("xdp: hold device for umem regardless of zero-copy mode")
Signed-off-by: NMarek Majtyka <marekx.majtyka@intel.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NMagnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20201120151443.105903-1-marekx.majtyka@intel.com
上级 537cf4e3
......@@ -185,8 +185,10 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool,
err_unreg_pool:
if (!force_zc)
err = 0; /* fallback to copy mode */
if (err)
if (err) {
xsk_clear_pool_at_qid(netdev, queue_id);
dev_put(netdev);
}
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册