Skip to contentSkip to conversation

usnix: correctly handle kzalloc return value

PATCH Applied Insu Yun 3 participants 3 messages Oct 17, 2015 – Oct 21, 2015

Subsystems (2)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 usnix: correctly handle kzalloc return value

Since kzalloc returns memory address, not error code, it should be checked whether it is null or not.

---
 drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +4 -4
index db3588d..a678a66 100644
@@ -221,8 +221,8 @@ create_roce_custom_flow(struct usnic_ib_qp_grp *qp_grp,
 
 	/* Create Flow Handle */
 	qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC);
-	if (IS_ERR_OR_NULL(qp_flow)) {
-		err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM;
+	if (!qp_flow) {
+		err = -ENOMEM;
 		goto out_dealloc_flow;
 	}
 	qp_flow->flow = flow;
@@ -296,8 +296,8 @@ create_udp_flow(struct usnic_ib_qp_grp *qp_grp,
 
 	/* Create qp_flow */
 	qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC);
-	if (IS_ERR_OR_NULL(qp_flow)) {
-		err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM;
+	if (!qp_flow) {
+		err = -ENOMEM;
 		goto out_dealloc_flow;
 	}
 	qp_flow->flow = flow;
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Insu Yun

Since kzalloc returns memory address, not error code, it should be checked whether it is null or not.

---
 drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

The subject says "usnix" where it should say "usnic". Otherwise:

If you have more of these fixes for drivers/infiniband/hw/usnic/, you can send them all through just Doug Ledford and linux-rdma@, no need to copy all of linux-kernel@. You can also CC me instead of Upinder, whose email bounces at this point, though I will see your patches sent to linux-rdma@ even if I'm not explicitly CC-ed. The patch to update MAINTAINERS for usnic has been submitted but hasn't yet percolated somewhere you would have seen it:

https://patchwork.kernel.org/patch/7410421/

-Dave
--
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

Applied
#2 lore raw
In reply to Insu Yun
Quoted 4 lines · Insu Yun

Since kzalloc returns memory address, not error code, it should be checked whether it is null or not.

Thanks, applied.

Quoted 31 lines
---
 drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +4 -4
index db3588d..a678a66 100644
@@ -221,8 +221,8 @@ create_roce_custom_flow(struct usnic_ib_qp_grp *qp_grp,
 
 	/* Create Flow Handle */
 	qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC);
-	if (IS_ERR_OR_NULL(qp_flow)) {
-		err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM;
+	if (!qp_flow) {
+		err = -ENOMEM;
 		goto out_dealloc_flow;
 	}
 	qp_flow->flow = flow;
@@ -296,8 +296,8 @@ create_udp_flow(struct usnic_ib_qp_grp *qp_grp,
 
 	/* Create qp_flow */
 	qp_flow = kzalloc(sizeof(*qp_flow), GFP_ATOMIC);
-	if (IS_ERR_OR_NULL(qp_flow)) {
-		err = qp_flow ? PTR_ERR(qp_flow) : -ENOMEM;
+	if (!qp_flow) {
+		err = -ENOMEM;
 		goto out_dealloc_flow;
 	}
 	qp_flow->flow = flow;
Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD