Whamcloud - gitweb
LU-17000 lnet: Initilize lnet_nidlist local variable 90/55290/2
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Mon, 3 Jun 2024 07:37:33 +0000 (03:37 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Jun 2024 01:14:01 +0000 (01:14 +0000)
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 <arshad.hussain@aeoncomputing.com>
Change-Id: I07de6a637c4567daed4ce7b35c54a1eed4d9bd2f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55290
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig.c

index e768d51..ec7decb 100644 (file)
@@ -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);