From 0fa2dd730753860e0f8f5397abbc1ee8eae2370f Mon Sep 17 00:00:00 2001 From: Jianxin Xiong Date: Sat, 7 Dec 2024 08:56:00 -0800 Subject: [PATCH] [v2.0.x] prov/psm2: Check return value of asprintf This fix a compiler warning of unused return value. Signed-off-by: Jianxin Xiong (cherry picked from commit cafbae7a68ca73367621146901d784b54a0f0ae2) --- prov/psm2/src/psmx2_attr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/prov/psm2/src/psmx2_attr.c b/prov/psm2/src/psmx2_attr.c index f7a1f5496d6..920ed918fe8 100644 --- a/prov/psm2/src/psmx2_attr.c +++ b/prov/psm2/src/psmx2_attr.c @@ -335,6 +335,7 @@ void psmx2_update_prov_info(struct fi_info *info, struct psmx2_ep_name *dest_addr) { struct fi_info *p; + int ret; for (p = info; p; p = p->next) { psmx2_dup_addr(p->addr_format, src_addr, @@ -363,10 +364,17 @@ void psmx2_update_prov_info(struct fi_info *info, } free(p->domain_attr->name); - if (unit == PSMX2_DEFAULT_UNIT) + if (unit == PSMX2_DEFAULT_UNIT) { p->domain_attr->name = strdup(psmx2_hfi_info.default_domain_name); - else - asprintf(&p->domain_attr->name, "hfi1_%d", unit); + } else { + ret = asprintf(&p->domain_attr->name, "hfi1_%d", unit); + if (ret < 0) { + p->domain_attr->name = NULL; + FI_WARN(&psmx2_prov, FI_LOG_CORE, + "Failed to allocate domain name for HFI unit %d\n", + unit); + } + } p->tx_attr->inject_size = psmx2_env.inject_size; }