ibdiag_sa.c: In sa_get_handle, handle umad_open_port and umad_register failures
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
@@ -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
ira.weiny
AppliedQuoted 4 lines · Hal Rosenstock
Treat
umad_open_portandumad_registererrors as failures forsa_get_handle
Thanks applied,
Ira
Quoted 32 lines
---
src/ibdiag_sa.c +13
-4@@ -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