Whamcloud - gitweb
LU-17962 mgc: free nidlist correctly 09/56709/7
authorEmoly Liu <emoly@whamcloud.com>
Wed, 23 Oct 2024 00:53:00 +0000 (08:53 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 24 Nov 2024 06:02:16 +0000 (06:02 +0000)
Memory leak was found during interop testing because
nidlist was not freed correctly in function
mgc_apply_recover_logs().

Test-Parameters: testlist=conf-sanity env=ONLY=29 \
  serverversion=2.15 clientdistro=el8.10 serverdistro=el8.10 \
  mdscount=2 mdtcount=4 ostcount=8

Fixes: e4d2d4ff74 ("LU-13306 mgc: handle large NID formats")
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I7a7a1b4b4f3b8c65c7608537e4dca1b9f1b68e77
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56709
Tested-by: Maloo <maloo@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre/mgc/mgc_request.c

index efb72a0..8d9d03d 100644 (file)
@@ -1345,8 +1345,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
                        CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n",
                               mgc->obd_name, obdname);
                        rc = 0;
-                       /* this is a safe race, when the ost is starting up...*/
-                       continue;
+                       goto free_nids;
                }
 
                /* osc.import = "connection=<Conn UUID>::<target instance>" */
@@ -1430,6 +1429,10 @@ fail:;
                                               bufs.lcfg_buflen));
                if (!lcfg) {
                        rc = -ENOMEM;
+                       /* For old NID format case the nidlist was allocated. */
+                       if (entry->mne_nid_type == 0)
+                               OBD_FREE_PTR_ARRAY(nidlist,
+                                                  entry->mne_nid_count);
                        break;
                }
                lustre_cfg_init(lcfg, LCFG_PARAM, &bufs);