Whamcloud - gitweb
LU-17673 obdclass: properly free opts string 50/54650/2
authorJames Simmons <jsimmons@infradead.org>
Tue, 2 Apr 2024 22:24:59 +0000 (18:24 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2024 15:39:50 +0000 (15:39 +0000)
With lmd_parse() rework being based on the llite match_table work
it inherited the same memory leak. Save the opts pointer to be
used bu kfree at the end.

Fixes: 415fa27540 ("LU-9325 obdclass: use match_table for server mount options")
Test-Parameters: trivial
Change-Id: I016f39f1512118486a0dc119ab075a1408b2a709
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54650
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/obd_mount.c

index caaee29..a841692 100644 (file)
@@ -1418,7 +1418,7 @@ failed:
  */
 int lmd_parse(char *options, struct lustre_mount_data *lmd)
 {
-       char *s1, *s2, *opts, *devname = NULL;
+       char *s1, *s2, *opts, *orig_opts, *devname = NULL;
        struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
        int rc = 0;
 
@@ -1443,6 +1443,7 @@ int lmd_parse(char *options, struct lustre_mount_data *lmd)
        opts = kstrdup(options, GFP_KERNEL);
        if (!opts)
                RETURN(-ENOMEM);
+       orig_opts = opts;
        s1 = opts;
 
        OBD_ALLOC(lmd->lmd_params, LMD_PARAMS_MAXLEN);
@@ -1748,7 +1749,7 @@ bad_string:
 invalid:
        if (rc < 0)
                CERROR("Bad mount options %s\n", options);
-       kfree(opts);
+       kfree(orig_opts);
 
        RETURN(rc);
 }