Skip to contentSkip to conversation

IB/hfi1: Fix an error code in hfi1_vnic_init()

PATCH In review Dan Carpenter 5 participants 10 messages May 29, 2020 – Jun 1, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/hfi1: Fix an error code in hfi1_vnic_init()

We should preserve the error code from hfi1_netdev_rx_init() but currently the function returns success instead.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
---
 drivers/infiniband/hw/hfi1/vnic_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/vnic_main.c +2 -1
index b183c56b7b6a4..f89d0cb1c7204 100644
@@ -512,7 +512,8 @@ static int hfi1_vnic_init(struct hfi1_vnic_vport_info *vinfo)
 			goto txreq_fail;
 	}
 
-	if (hfi1_netdev_rx_init(dd)) {
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc) {
 		dd_dev_err(dd, "Unable to initialize netdev contexts\n");
 		goto alloc_fail;
 	}
Signature · 1 line
2.26.2
#1 lore raw
Quoted 16 lines

From: Dan Carpenter <[email protected]>

drivers/infiniband/hw/hfi1/vnic_main.c +2 -1
index b183c56b7b6a4..f89d0cb1c7204 100644
@@ -512,7 +512,8 @@ static int hfi1_vnic_init(struct hfi1_vnic_vport_info
 *vinfo)
 			goto txreq_fail;
 	}
 
-	if (hfi1_netdev_rx_init(dd)) {
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc) {
 		dd_dev_err(dd, "Unable to initialize netdev contexts\n");
 		goto alloc_fail;
Quoted 1 line

}

Dan,

This is definitely wrong, but another call to hfi1_netdev_rx_init() exists in hfi1_vnic_up() that needs to be fixed.

Can you address that too?

Mike

#2 lore raw

PATCH v2 1/1 IB/hfi1: Fix hfi1_netdev_rx_init() error handling

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +9 -2
index b183c56b7b6a4..03f8be8e9488e 100644
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo)
 	if (rc < 0)
 		return rc;
 
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)
+		goto err_remove;
 
 	netif_carrier_on(netdev);
 	netif_tx_start_all_queues(netdev);
 	set_bit(HFI1_VNIC_UP, &vinfo->flags);
 
 	return 0;
+
+err_remove:
+	hfi1_netdev_remove_data(dd, VNIC_ID(vinfo->vesw_id));
+	return rc;
 }
 
 static void hfi1_vnic_down(struct hfi1_vnic_vport_info *vinfo)
@@ -512,7 +518,8 @@ static int hfi1_vnic_init(struct hfi1_vnic_vport_info *vinfo)
 			goto txreq_fail;
 	}
 
-	if (hfi1_netdev_rx_init(dd)) {
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc) {
 		dd_dev_err(dd, "Unable to initialize netdev contexts\n");
 		goto alloc_fail;
 	}
Signature · 1 line
2.26.2
#3 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 18 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +0 -0
index b183c56b7b6a4..03f8be8e9488e 100644

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 462

Quoted 7 lines
drivers/infiniband/hw/hfi1/vnic_main.c +3 -1
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo)
 	if (rc < 0)
 		return rc;
 
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)
+		goto err_remove;

Why did you check for the negative value here and didn't check below?

Thanks

Quoted 26 lines
drivers/infiniband/hw/hfi1/vnic_main.c +6 -2
 	netif_carrier_on(netdev);
 	netif_tx_start_all_queues(netdev);
 	set_bit(HFI1_VNIC_UP, &vinfo->flags);
 
 	return 0;
+
+err_remove:
+	hfi1_netdev_remove_data(dd, VNIC_ID(vinfo->vesw_id));
+	return rc;
 }
 
 static void hfi1_vnic_down(struct hfi1_vnic_vport_info *vinfo)
@@ -512,7 +518,8 @@ static int hfi1_vnic_init(struct hfi1_vnic_vport_info *vinfo)
 			goto txreq_fail;
 	}
 
-	if (hfi1_netdev_rx_init(dd)) {
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc) {
 		dd_dev_err(dd, "Unable to initialize netdev contexts\n");
 		goto alloc_fail;
 	}
--

2.26.2

#4 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 22 lines · Leon Romanovsky
Quoted 21 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +0 -0
index b183c56b7b6a4..03f8be8e9488e 100644
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo)
 	if (rc < 0)
 		return rc;
 
Quoted 7 lines

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 462

Quoted 4 lines
drivers/infiniband/hw/hfi1/vnic_main.c +3 -1
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)
+		goto err_remove;

Why did you check for the negative value here and didn't check below?

I just copied the pattern in the nearest code. I didn't realize until now that it was different in both functions... The checking isn't done consistently in this file.

I can resend on Tuesday though if you want.

regards,
dan carpenter

#5 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 31 lines · Dan Carpenter
Quoted 22 lines · Leon Romanovsky
Quoted 21 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +0 -0
index b183c56b7b6a4..03f8be8e9488e 100644
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo)
 	if (rc < 0)
 		return rc;
 
Quoted 7 lines

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 462

Quoted 4 lines
drivers/infiniband/hw/hfi1/vnic_main.c +3 -1
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)
+		goto err_remove;

Why did you check for the negative value here and didn't check below?

Quoted 5 lines

I just copied the pattern in the nearest code. I didn't realize until now that it was different in both functions... The checking isn't done consistently in this file.

I can resend on Tuesday though if you want.

I imagine that Jason will fix it once he will apply the patch.

Thanks

Quoted 4 lines

regards,
dan carpenter

#6 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 30 lines · Leon Romanovsky
Quoted 29 lines · Dan Carpenter
Quoted 27 lines · Leon Romanovsky
Quoted 16 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +1 -0
index b183c56b7b6a4..03f8be8e9488e 100644
+++ b/drivers/infiniband/hw/hfi1/vnic_main.c

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 462

Quoted 7 lines
drivers/infiniband/hw/hfi1/vnic_main.c +3 -1
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo)
 	if (rc < 0)
 		return rc;
 
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)
+		goto err_remove;

Why did you check for the negative value here and didn't check below?

Quoted 7 lines
Quoted 5 lines

I just copied the pattern in the nearest code. I didn't realize until now that it was different in both functions... The checking isn't done consistently in this file.

I can resend on Tuesday though if you want.

I imagine that Jason will fix it once he will apply the patch.

If someone from hfi says which is the right one, sure..

Jason

#7 lore raw

RE: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 39 lines

-----Original Message-----
From: [email protected] <linux-rdma- [email protected]> On Behalf Of Jason Gunthorpe
Sent: Monday, June 01, 2020 8:27 AM
To: Leon Romanovsky <[email protected]>
Cc: Dan Carpenter <[email protected]>; Marciniszyn, Mike <[email protected]>; Andrejczuk, Grzegorz <[email protected]>; Dalessandro, Dennis <[email protected]>; Doug Ledford <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 6 lines · Leon Romanovsky
Quoted 5 lines · Dan Carpenter
Quoted 4 lines · Leon Romanovsky
Quoted 3 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of

returning success.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface

Controller (VNIC) HW support")

Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

v2: Add error handling in hfi1_vnic_up() and add second fixes tag

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct

Quoted 8 lines
 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/vnic_main.c +1 -0
index b183c56b7b6a4..03f8be8e9488e 100644
+++ b/drivers/infiniband/hw/hfi1/vnic_main.c
@@ -457,13 +457,19 @@ static int hfi1_vnic_up(struct

hfi1_vnic_vport_info *vinfo)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 461

Quoted 6 lines
drivers/infiniband/hw/hfi1/vnic_main.c +2 -1
 	if (rc < 0)
 		return rc;
 
-	hfi1_netdev_rx_init(dd);
+	rc = hfi1_netdev_rx_init(dd);
+	if (rc < 0)

Please use: if (rc)

Thanks,

Kaike

Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

drivers/infiniband/hw/hfi1/vnic_main.c static int hfi1_vnic_up(struct hfi1_vnic_vport_info *vinfo) · line 462

Quoted 1 line
drivers/infiniband/hw/hfi1/vnic_main.c +1 -0
+		goto err_remove;

Why did you check for the negative value here and didn't check below?

Quoted 7 lines
Quoted 5 lines

I just copied the pattern in the nearest code. I didn't realize until now that it was different in both functions... The checking isn't done consistently in this file.

I can resend on Tuesday though if you want.

I imagine that Jason will fix it once he will apply the patch.

If someone from hfi says which is the right one, sure..

Jason

#8 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Quoted 8 lines
Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Applied to for-next with the 'if (rc)' fixup, thanks

Jason

#9 lore raw

Re: [PATCH v2] IB/hfi1: Fix hfi1_netdev_rx_init() error handling

Quoted 11 lines · Jason Gunthorpe
Quoted 10 lines · Dan Carpenter

The hfi1_vnic_up() function doesn't check whether hfi1_netdev_rx_init() returns errors. In hfi1_vnic_init() we need to change the code to preserve the error code instead of returning success.

Fixes 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
Fixes 4730f4a6c6b2 ("IB/hfi1: Activate the dummy netdev")

---
v2: Add error handling in hfi1_vnic_up() and add second fixes tag

Quoted 4 lines
Quoted 2 lines
 drivers/infiniband/hw/hfi1/vnic_main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Applied to for-next with the 'if (rc)' fixup, thanks

Thanks. I would have resent it, but it's a three day weekend here...

regards,
dan carpenter