From f2b5a3dab4fa763d35cf89a007b1467b7fb5bd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kajetan=20=C5=9Awierk?= Date: Thu, 16 Nov 2023 00:21:06 +0100 Subject: [PATCH] prov/verbs_nd: Check error code from GetPrivateData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On ECONNREFUSED Mellanox drivers return 0xc000023a while still writing to `len` a non-zero value. This commit addresses the issue by checking both the error code and `len` for non-zero values. Signed-off-by: Kajetan Świerk --- prov/verbs/src/windows/verbs_nd_ov.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/prov/verbs/src/windows/verbs_nd_ov.c b/prov/verbs/src/windows/verbs_nd_ov.c index a1babb5da10..4991b0cd86f 100644 --- a/prov/verbs/src/windows/verbs_nd_ov.c +++ b/prov/verbs/src/windows/verbs_nd_ov.c @@ -127,8 +127,8 @@ void nd_get_connection_data(IND2Connector *connector, struct nd_cm_event *event) FI_LOG_EP_CTRL, "IND2Connector::GetPrivateData: hr=0x%08lx\n", hr); - event->event.param.conn.private_data_len = (uint8_t)len; - if (len) { + if (SUCCEEDED(hr) && len) { + event->event.param.conn.private_data_len = (uint8_t)len; event->event.param.conn.private_data = malloc(len); if (event->event.param.conn.private_data) { hr = connector->lpVtbl->GetPrivateData( @@ -140,6 +140,11 @@ void nd_get_connection_data(IND2Connector *connector, struct nd_cm_event *event) FI_LOG_EP_CTRL, "IND2Connector::GetPrivateData: hr=0x%08lx\n", hr); + if (FAILED(hr)) { + free(event->event.param.conn.private_data); + event->event.param.conn.private_data = NULL; + event->event.param.conn.private_data_len = 0; + } } else { event->event.param.conn.private_data_len = 0; VRB_WARN( @@ -147,6 +152,7 @@ void nd_get_connection_data(IND2Connector *connector, struct nd_cm_event *event) "Failed to allocate memory for connection data.\n"); } } else { + event->event.param.conn.private_data_len = 0; event->event.param.conn.private_data = NULL; } }