btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options()
PATCH 1/1 btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options()
--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/super.c +8 -2
@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;int error =0 ;int intarg;
@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;break ;
Signature · 1 line
1.7.4.1
Quoted 11 lines · Jeff Liu
Signed-off-by Jie Liu <[email protected]>--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)fs/btrfs/super.c +0
-0
fs/btrfs/super.c static int btrfs_parse_early_options(const char *options, fmode_t flags, · line 409
Quoted 5 lines
fs/btrfs/super.c +1
-1@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;
Seems your email client replaced tabs with spaces.
Please read Documentation/email-clients.txt
Quoted 19 lines
fs/btrfs/super.c +7
-1int error =0 ;int intarg;@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;break ;
Quoted 7 lines · Li Zefan
Quoted 6 lines · Jeff Liu
Signed-off-by Jie Liu <[email protected]>--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
Quoted 12 lines
fs/btrfs/super.c static int btrfs_parse_early_options(const char *options, fmode_t flags, · line 409
Quoted 10 lines
fs/btrfs/super.c +1
-1@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;Seems your email client replaced tabs with spaces.
Fixed, thank you.
--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/super.c +0 -0
@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char
*options, fmode_t flags,
u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices)
{
substring_t args[MAX_OPT_ARGS];
- char *opts, *orig, *p;
+ char *device_name, *opts, *orig, *p;
int error = 0;
int intarg;
@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
}
break;
case Opt_device:
- error = btrfs_scan_one_device(match_strdup(&args[0]),
+ device_name = match_strdup(&args[0]);
+ if (!device_name) {
+ error = -ENOMEM;
+ goto out_free_opts;
+ }
+ error = btrfs_scan_one_device(device_name,
flags, holder, fs_devices);
+ kfree(device_name);
if (error)
goto out_free_opts;
break;
Signature · 1 line
1.7.4.1
Quoted 26 lines
Please read
Documentation/email-clients.txtQuoted 9 lines
fs/btrfs/super.c +1
-1int error =0 ;int intarg;@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error = btrfs_scan_one_device(match_strdup(&args[0]), + device_name =match_strdup (&args[0 ]);fs/btrfs/super.c static int btrfs_parse_early_options(const char *options, fmode_t flags, · line 470
Quoted 10 lines
fs/btrfs/super.c +6
-0+if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;break ;--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 35 lines · Jeff Liu
Quoted 7 lines · Li Zefan
Quoted 6 lines · Jeff Liu
Signed-off-by Jie Liu <[email protected]>--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)Quoted 12 lines
fs/btrfs/super.c static int btrfs_parse_early_options(const char *options, fmode_t flags, · line 409
Quoted 10 lines
fs/btrfs/super.c +1
-1@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;Seems your email client replaced tabs with spaces.
Fixed, thank you.
Signed-off-by Jie Liu <[email protected]>--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)fs/btrfs/super.c +0
-0
fs/btrfs/super.c static int btrfs_parse_early_options(const char · line 406
Quoted 1 line
fs/btrfs/super.c +0
-0@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
^^^^^^^^^^^^^^^^^^^^^^^^
long lines are still getting wrapped.
fs/btrfs/super.c static int btrfs_parse_early_options(const char · line 457
Quoted 10 lines
fs/btrfs/super.c +1
-1u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;int error =0 ;int intarg;@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags,
^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 14 lines
fs/btrfs/super.c +7
-1}break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;
Quoted 3 lines
break;
Signature · 1 line
1.7.4.1
and you do not need to keep unrelated replies and signatures (like the following quoted text). Just send the patch again with proper changelog and add a version tag eg
[PATCH v2] btrfs: ...
It's really annoying to hand fix corrupted patches from mailinglist,
Quoted 34 lines
Quoted 20 lines
Please read
Documentation/email-clients.txtQuoted 15 lines
fs/btrfs/super.c +6
-1int error =0 ;int intarg;@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices);Quoted 8 lines
fs/btrfs/super.c static int btrfs_parse_early_options(const char *options, fmode_t flags, · line 470
Quoted 4 lines
fs/btrfs/super.c +1
-0+kfree (device_name);if (error) goto out_free_opts;break ;--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 btrfs: trivial fix, a potential memory leak in btrfs_parse_early_options()
--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/super.c +8 -2
@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;int error =0 ;int intarg;
@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;break ;
Signature · 1 line
1.7.4.1
Quoted 1 line · Jeff Liu
Signed-off-by Jie Liu <[email protected]>
Quoted 40 lines
--- fs/btrfs/super.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)fs/btrfs/super.c +8
-2@@ -406,7 +406,7 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, u64 *subvol_rootid, struct btrfs_fs_devices **fs_devices) { substring_t args[MAX_OPT_ARGS]; -char *opts, *orig, *p; +char *device_name, *opts, *orig, *p;int error =0 ;int intarg;@@ -457,8 +457,14 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, }break ;case Opt_device: - error =btrfs_scan_one_device (match_strdup (&args[0 ]), + device_name =match_strdup (&args[0 ]); +if (!device_name) { + error = -ENOMEM ; + goto out_free_opts; + } + error =btrfs_scan_one_device (device_name, flags, holder, fs_devices); +kfree (device_name);if (error) goto out_free_opts;break ;Signature · 5 lines
1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html