From: James Simmons Date: Tue, 2 Apr 2024 22:24:59 +0000 (-0400) Subject: LU-17673 obdclass: properly free opts string X-Git-Tag: 2.15.62~3 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=53c3585ac3b616443295b2413eace75ded00552b;p=fs%2Flustre-release.git LU-17673 obdclass: properly free opts string 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 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54650 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index caaee29..a841692 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -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); }