diff mbox

btrfs: cleanup unnecessary string dup in btrfs_parse_options()

Message ID 0530ed22-f85e-ad17-58f3-9f4d147f8430@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Misono Tomohiro Dec. 14, 2017, 8:28 a.m. UTC
Long ago, commit edf24abe51493 ("btrfs: sanity mount option parsing and
early mount code") split the btrfs_parse_options() into two parts
(btrfs_parse_early_options() and btrfs_parse_options()). As a result,
btrfs_parse_optins no longer gets called twice and is the last one to parse
mount option string. Therefore there is no need to dup it.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
---
 fs/btrfs/super.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

David Sterba Jan. 2, 2018, 5:15 p.m. UTC | #1
On Thu, Dec 14, 2017 at 05:28:00PM +0900, Misono, Tomohiro wrote:
> Long ago, commit edf24abe51493 ("btrfs: sanity mount option parsing and
> early mount code") split the btrfs_parse_options() into two parts
> (btrfs_parse_early_options() and btrfs_parse_options()). As a result,
> btrfs_parse_optins no longer gets called twice and is the last one to parse
> mount option string. Therefore there is no need to dup it.
> 
> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>

Reviewed-by: David Sterba <dsterba@suse.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7da78cb8a946..69c1ed398513 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -411,7 +411,7 @@  int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
 			unsigned long new_flags)
 {
 	substring_t args[MAX_OPT_ARGS];
-	char *p, *num, *orig = NULL;
+	char *p, *num;
 	u64 cache_gen;
 	int intarg;
 	int ret = 0;
@@ -434,16 +434,6 @@  int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
 	if (!options)
 		goto check;
 
-	/*
-	 * strsep changes the string, duplicate it because parse_options
-	 * gets called twice
-	 */
-	options = kstrdup(options, GFP_KERNEL);
-	if (!options)
-		return -ENOMEM;
-
-	orig = options;
-
 	while ((p = strsep(&options, ",")) != NULL) {
 		int token;
 		if (!*p)
@@ -884,7 +874,6 @@  int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
 		btrfs_info(info, "disk space caching is enabled");
 	if (!ret && btrfs_test_opt(info, FREE_SPACE_TREE))
 		btrfs_info(info, "using free space tree");
-	kfree(orig);
 	return ret;
 }