btrfs: Free correct pointer after using strsep
diff mbox

Message ID alpine.LFD.2.00.1008301609440.10601@localhost6.localdomain6
State New, archived
Headers show

Commit Message

Tero Roponen Aug. 30, 2010, 1:14 p.m. UTC
None

Patch
diff mbox

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1776dbd..9e2c9ec 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -260,7 +260,7 @@  static int btrfs_parse_early_options(const char *options, fmode_t flags,
 		struct btrfs_fs_devices **fs_devices)
 {
 	substring_t args[MAX_OPT_ARGS];
-	char *opts, *p;
+	char *opts, *orig, *p;
 	int error = 0;
 	int intarg;
 
@@ -275,6 +275,8 @@  static int btrfs_parse_early_options(const char *options, fmode_t flags,
 	if (!opts)
 		return -ENOMEM;
 
+	orig = opts;
+
 	while ((p = strsep(&opts, ",")) != NULL) {
 		int token;
 		if (!*p)
@@ -309,7 +311,7 @@  static int btrfs_parse_early_options(const char *options, fmode_t flags,
 	}
 
  out_free_opts:
-	kfree(opts);
+	kfree(orig);
  out:
 	/*
 	 * If no subvolume name is specified we use the default one.  Allocate