Skip to contentSkip to conversation

RDMA/nes: checking for NULL instead of IS_ERR

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 12, 2016 – Jan 19, 2016

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

PATCH 1/1 RDMA/nes: checking for NULL instead of IS_ERR

nes_reg_phys_mr() returns ERR_PTRs on error. It doesn't return NULL.

This bug has been there for a while, but we recently changed from calling a function pointer to calling nes_reg_phys_mr() directly so now Smatch is able to detect the bug.

drivers/infiniband/hw/nes/nes_cm.c +2 -2
index 179490d..cb9f0f2 100644
@@ -3320,14 +3320,14 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
 				nesqp->ietf_frame_pbase + mpa_frame_offset,
 				buff_len, IB_ACCESS_LOCAL_WRITE,
 				&tagged_offset);
-		if (!ibmr) {
+		if (IS_ERR(ibmr)) {
 			nes_debug(NES_DBG_CM, "Unable to register memory region"
 				  "for lSMM for cm_node = %p \n",
 				  cm_node);
 			pci_free_consistent(nesdev->pcidev,
 					    nesqp->private_data_len + nesqp->ietf_frame_size,
 					    nesqp->ietf_frame, nesqp->ietf_frame_pbase);
-			return -ENOMEM;
+			return PTR_ERR(ibmr);
 		}
 
 		ibmr->pd = &nespd->ibpd;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

nes_reg_phys_mr() returns ERR_PTRs on error. It doesn't return NULL.

This bug has been there for a while, but we recently changed from calling a function pointer to calling nes_reg_phys_mr() directly so now Smatch is able to detect the bug.

Looks fine,

Applied
#2 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Dan Carpenter

nes_reg_phys_mr() returns ERR_PTRs on error. It doesn't return NULL.

This bug has been there for a while, but we recently changed from calling a function pointer to calling nes_reg_phys_mr() directly so now Smatch is able to detect the bug.

Looks fine,

Thanks, applied.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD