reiserfs: kstrdup() memory handling
PATCH 1/1 reiserfs: kstrdup() memory handling
Checking for ENOMEM even for new_opts in reiserfs_remount function as there is a possibility of nothing being allocated.
--- fs/reiserfs/super.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/reiserfs/super.c +6 -0
@@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)int i;#endif +if (!new_opts) { + err = -ENOMEM ; + goto out_err_no_kfree; + } +sync_filesystem (s);reiserfs_write_lock (s);
@@ -1549,6 +1554,7 @@ out_err_unlock:reiserfs_write_unlock (s); out_err:kfree (new_opts); +out_err_no_kfree:return err; }
Signature · 1 line
2.1.0
Quoted 2 lines · Sanidhya Kashyap
Checking for ENOMEM even for
new_optsinreiserfs_remountfunction as there is a possibility of nothing being allocated.
You don't need to add a new label; kfree(NULL) is a no-op.
Quoted 32 lines
Signed-off-by Sanidhya Kashyap <[email protected]>--- fs/reiserfs/super.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/reiserfs/super.c +6
-0@@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)int i;#endif +if (!new_opts) { + err = -ENOMEM ; + goto out_err_no_kfree; + } +sync_filesystem (s);reiserfs_write_lock (s);@@ -1549,6 +1554,7 @@ out_err_unlock:reiserfs_write_unlock (s); out_err:kfree (new_opts); +out_err_no_kfree:return err; }Signature · 1 line
2.1.0
Quoted 6 lines · Josh Triplett
Quoted 2 lines · Sanidhya Kashyap
Checking for ENOMEM even for
new_optsinreiserfs_remountfunction as there is a possibility of nothing being allocated.You don't need to add a new label; kfree(NULL) is a no-op.
Shall I resubmit the patch?
Thanks,
Sanidhya
Quoted 32 lines
Quoted 32 lines
Signed-off-by Sanidhya Kashyap <[email protected]>--- fs/reiserfs/super.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/reiserfs/super.c +6
-1@@ -1397,6 +1397,11 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)int i;#endif +if (!new_opts) { + err = -ENOMEM ; + goto out_err_no_kfree; + } +sync_filesystem (s);reiserfs_write_lock (s);@@ -1549,6 +1554,7 @@ out_err_unlock:reiserfs_write_unlock (s); out_err:kfree (new_opts); +out_err_no_kfree:return err; } --2.1.0
Quoted 9 lines · Sanidhya Kashyap
Quoted 6 lines · Josh Triplett
Quoted 2 lines · Sanidhya Kashyap
Checking for ENOMEM even for
new_optsinreiserfs_remountfunction as there is a possibility of nothing being allocated.You don't need to add a new label; kfree(NULL) is a no-op.
Shall I resubmit the patch?
I would suggest doing so, yes, after you see if anyone else has feedback on it.
- Josh Triplett