Skip to contentSkip to conversation

RDMA/bnxt_re: Adjustments for bnxt_qplib_alloc_dpi_tbl()

PATCH Applied SF Markus Elfring 4 participants 8 messages Jan 27, 2018 – Feb 1, 2018

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

cover RDMA/bnxt_re: Adjustments for bnxt_qplib_alloc_dpi_tbl()

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code

 drivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/2 RDMA/bnxt_re: Delete two error messages for a failed memory allocation in bnxt_qplib_alloc_dpi_tbl()

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 20:40:11 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/infiniband/hw/bnxt_re/qplib_res.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +0 -5
index ad37d54affcc..9dacfd24869b 100644
@@ -707,8 +707,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res     *res,
 	dpit->app_tbl = kcalloc(dpit->max, sizeof(void *), GFP_KERNEL);
 	if (!dpit->app_tbl) {
 		pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
-		dev_err(&res->pdev->dev,
-			"QPLIB: DPI app tbl allocation failed");
 		return -ENOMEM;
 	}
 
@@ -721,9 +719,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res     *res,
 		pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
 		kfree(dpit->app_tbl);
 		dpit->app_tbl = NULL;
-		dev_err(&res->pdev->dev,
-			"QPLIB: DPI tbl allocation failed for size = %d",
-			bytes);
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.16.1
#2 lore raw

PATCH 2/2 RDMA/bnxt_re: Use common error handling code in bnxt_qplib_alloc_dpi_tbl()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 20:56:56 +0100

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

---
 drivers/infiniband/hw/bnxt_re/qplib_res.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +7 -6
index 9dacfd24869b..539a5d44e6db 100644
@@ -705,10 +705,8 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res     *res,
 	dpit->max = dbr_len / PAGE_SIZE;
 
 	dpit->app_tbl = kcalloc(dpit->max, sizeof(void *), GFP_KERNEL);
-	if (!dpit->app_tbl) {
-		pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
-		return -ENOMEM;
-	}
+	if (!dpit->app_tbl)
+		goto unmap_io;
 
 	bytes = dpit->max >> 3;
 	if (!bytes)
@@ -716,15 +714,18 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res     *res,
 
 	dpit->tbl = kmalloc(bytes, GFP_KERNEL);
 	if (!dpit->tbl) {
-		pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
 		kfree(dpit->app_tbl);
 		dpit->app_tbl = NULL;
-		return -ENOMEM;
+		goto unmap_io;
 	}
 
 	memset((u8 *)dpit->tbl, 0xFF, bytes);
 
 	return 0;
+
+unmap_io:
+	pci_iounmap(res->pdev, dpit->dbr_bar_reg_iomem);
+	return -ENOMEM;
 }
 
 /* PKEYs */
Signature · 1 line
2.16.1
Reviewed-by on the v1 series
#3 lore raw
In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100

Two update suggestions were taken into account
from static source code analysis.

You don't need 2 patches when changing same lines of code. Could you squash both and send your changes in a single patch. The patches look good to me otherwise.
-Thanks

Quoted 8 lines

Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code

 drivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
Quoted 7 lines

--
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 1 line

You don't need 2 patches when changing same lines of code.

Are these really the same?

Quoted 1 line

Could you squash both and send your changes in a single patch.

I prefer to keep the deletion of questionable error messages separate from the refactoring for a bit of exception handling.

Quoted 1 line

The patches look good to me otherwise.

Thanks for your constructive feedback.

Regards,
Markus

#5 lore raw
Quoted 10 lines · SF Markus Elfring
Quoted 1 line

You don't need 2 patches when changing same lines of code.

Are these really the same?

Quoted 1 line

Could you squash both and send your changes in a single patch.

I prefer to keep the deletion of questionable error messages separate from the refactoring for a bit of exception handling.

Okay fair enough
Series Acked-By: Devesh Sharma <devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]>

Quoted 11 lines
Quoted 2 lines

The patches look good to me otherwise.

Thanks for your constructive feedback.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on the v1 series
#6 lore raw
In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100

Two update suggestions were taken into account
from static source code analysis.

Quoted 7 lines

Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code

 drivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

I like it.

#7 lore raw
In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code

Applied to for-next with Jonathan and Devesh's ack, thanks all

Jason