Skip to contentSkip to conversation

ibdiag_sa.c: In sa_get_handle, handle umad_open_port and umad_register failures

PATCH Applied Hal Rosenstock 2 participants 2 messages May 7, 2015 – Jul 3, 2015 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibdiag_sa.c: In sa_get_handle, handle umad_open_port and umad_register failures

Treat umad_open_port and umad_register errors as failures for sa_get_handle

---

src/ibdiag_sa.c +18 -4
index 018a428..a089aee 100644
@@ -60,18 +60,32 @@ struct sa_handle * sa_get_handle(void)
 		IBWARN("No SM/SA found on port %s:%d",
 			ibd_ca ? "" : ibd_ca,
 			ibd_ca_port);
-		free(handle);
-		return (NULL);
+		goto err;
 	}
 
 	handle->dport.qp = 1;
 	if (!handle->dport.qkey)
 		handle->dport.qkey = IB_DEFAULT_QP1_QKEY;
 
-	handle->fd = umad_open_port(ibd_ca, ibd_ca_port);
-	handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL);
+	if ((handle->fd = umad_open_port(ibd_ca, ibd_ca_port)) < 0) {
+		IBWARN("umad_open_port on port %s:%d failed",
+			ibd_ca ? "" : ibd_ca,
+			ibd_ca_port);
+		goto err;
+	}
+	if ((handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL)) < 0) {
+		umad_close_port(handle->fd);
+		IBWARN("umad_register for SA class failed on port %s:%d",
+		       ibd_ca ? "" : ibd_ca,
+		       ibd_ca_port);
+		goto err;
+	}
 
 	return handle;
+
+err:
+	free(handle);
+	return (NULL);
 }
 
 void sa_free_handle(struct sa_handle * h)

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

A message that is not in the archive (sent off-list or not yet received): 554B447C.1040003-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

Applied
#2 lore raw
Quoted 4 lines · Hal Rosenstock

Treat umad_open_port and umad_register errors as failures for sa_get_handle

Thanks applied,
Ira

Quoted 32 lines

---

src/ibdiag_sa.c +13 -4
index 018a428..a089aee 100644
@@ -60,18 +60,32 @@ struct sa_handle * sa_get_handle(void)
 		IBWARN("No SM/SA found on port %s:%d",
 			ibd_ca ? "" : ibd_ca,
 			ibd_ca_port);
-		free(handle);
-		return (NULL);
+		goto err;
 	}
 
 	handle->dport.qp = 1;
 	if (!handle->dport.qkey)
 		handle->dport.qkey = IB_DEFAULT_QP1_QKEY;
 
-	handle->fd = umad_open_port(ibd_ca, ibd_ca_port);
-	handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL);
+	if ((handle->fd = umad_open_port(ibd_ca, ibd_ca_port)) < 0) {
+		IBWARN("umad_open_port on port %s:%d failed",
+			ibd_ca ? "" : ibd_ca,
+			ibd_ca_port);
+		goto err;
+	}
+	if ((handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL)) < 0) {
+		umad_close_port(handle->fd);
+		IBWARN("umad_register for SA class failed on port %s:%d",
+		       ibd_ca ? "" : ibd_ca,
+		       ibd_ca_port);
+		goto err;

src/ibdiag_sa.c struct sa_handle * sa_get_handle(void) · line 91

Quoted 10 lines
src/ibdiag_sa.c +5 -0
+	}
 
 	return handle;
+
+err:
+	free(handle);
+	return (NULL);
 }
 
 void sa_free_handle(struct sa_handle * h)

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