Skip to content

Commit

Permalink
xdp: move the if dev statements to the first
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yajun Deng authored and David S. Miller committed Dec 18, 2021
1 parent 23044d7 commit f85b244
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/core/xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit f85b244

Please sign in to comment.