diff options
author | Yajun Deng <yajun.deng@linux.dev> | 2021-12-17 10:25:45 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-12-18 13:35:49 +0100 |
commit | f85b244ee395c774a0039c176f46fc0d3747a0ae (patch) | |
tree | 556a42c4754b29b988b23b9823a10a86d2b47ef5 /net/core | |
parent | Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/n... (diff) | |
download | linux-f85b244ee395c774a0039c176f46fc0d3747a0ae.tar.xz linux-f85b244ee395c774a0039c176f46fc0d3747a0ae.zip |
xdp: move the if dev statements to the first
The xdp_rxq_info_unreg() called by xdp_rxq_info_reg() is meaningless when
dev is NULL, so move the if dev statements to the first.
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/xdp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/core/xdp.c b/net/core/xdp.c index 5ddc29f29bad..7fe1df85f505 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -159,6 +159,11 @@ static void xdp_rxq_info_init(struct xdp_rxq_info *xdp_rxq) int xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq, struct net_device *dev, u32 queue_index, unsigned int napi_id) { + if (!dev) { + WARN(1, "Missing net_device from driver"); + return -ENODEV; + } + if (xdp_rxq->reg_state == REG_STATE_UNUSED) { WARN(1, "Driver promised not to register this"); return -EINVAL; @@ -169,11 +174,6 @@ int xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq, xdp_rxq_info_unreg(xdp_rxq); } - if (!dev) { - WARN(1, "Missing net_device from driver"); - return -ENODEV; - } - /* State either UNREGISTERED or NEW */ xdp_rxq_info_init(xdp_rxq); xdp_rxq->dev = dev; |