From 61d420120672c204f6be68dfbbdf99d2c54ed09b Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Mon, 3 Jun 2024 03:37:33 -0400 Subject: [PATCH] LU-17000 lnet: Initilize lnet_nidlist local variable Initialize vairbale lnet_nidlist under lustre_lnet_modify_peer(). This is due to a case where "nids" is false lustre_lnet_mod_peer_nidlist() is called with lnet_nidlist uninitialized. Test-Parameters: trivial testlist=sanity-lnet CoverityID 397609: ("Uninitialized scalar variable") Signed-off-by: Arshad Hussain Change-Id: I07de6a637c4567daed4ce7b35c54a1eed4d9bd2f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55290 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Serguei Smirnov Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/utils/lnetconfig/liblnetconfig.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lnet/utils/lnetconfig/liblnetconfig.c b/lnet/utils/lnetconfig/liblnetconfig.c index e768d51..ec7decb 100644 --- a/lnet/utils/lnetconfig/liblnetconfig.c +++ b/lnet/utils/lnetconfig/liblnetconfig.c @@ -867,7 +867,7 @@ int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr, int cmd, { int num_nids, rc; char err_str[LNET_MAX_STR_LEN] = "Error"; - lnet_nid_t lnet_nidlist[LNET_MAX_NIDS_PER_PEER]; + lnet_nid_t lnet_nidlist[LNET_MAX_NIDS_PER_PEER] = {0}; lnet_nid_t pnid = LNET_NID_ANY; if (!prim_nid) { @@ -887,10 +887,9 @@ int lustre_lnet_modify_peer(char *prim_nid, char *nids, bool is_mr, int cmd, num_nids = 0; if (nids) { - /* - * if there is no primary nid we need to make the first nid in the - * nids list the primary nid - */ + /* if there is no primary nid we need to make the first nid in + * the nids list the primary nid + */ replace_sep(nids, ',', ' '); rc = lustre_lnet_parse_nidstr(nids, lnet_nidlist, LNET_MAX_NIDS_PER_PEER, err_str); -- 1.8.3.1