Skip to contentSkip to conversation

xdp: move the if dev statements to the first

PATCH Applied Yajun Deng 2 participants 2 messages Dec 17, 2021 – Dec 18, 2021

Subsystems (4)
lore
Share & tools
lore

Yajun Deng

author
#0 lore raw

PATCH 1/1 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.

---
 net/core/xdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
net/core/xdp.c +5 -5
index 5ddc29f29bad..7fe1df85f505 100644
@@ -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;
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 7 lines · On Fri, 17 Dec 2021 17:25:45 +0800 you wrote:

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.

---
 net/core/xdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Here is the summary with links:
- [net-next] xdp: move the if dev statements to the first

    https://git.kernel.org/netdev/net-next/c/f85b244ee395

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html