afs: kstrdup() memory handling
Subsystems (2)
PATCH 1/1 afs: kstrdup() memory handling
Handling kstrdup() failure in case of memory pressure even for new_opts.
Signed-off-by Sanidhya Kashyap <[email protected]>
--- fs/afs/super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/afs/super.c +5 -1
@@ -360,10 +360,13 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,struct key *key;char *new_opts =kstrdup (options,GFP_KERNEL );struct afs_super_info *as; -int ret; +int ret = -ENOMEM ;_enter (",,%s,%p" , dev_name, options); +if (new_opts) + goto error_out; +memset (¶ms,0 ,sizeof (params)); ret = -EINVAL ;
@@ -441,6 +444,7 @@ error:afs_put_cell (params.cell);key_put (params.key);kfree (new_opts); +error_out:_leave (" = %d" , ret);return ERR_PTR (ret); }
Signature · 1 line
2.1.0
fs/afs/super.c static struct dentry *afs_mount(struct file_system_type *fs_type, · line 368
Quoted 2 lines · Sanidhya Kashyap
fs/afs/super.c +2
-0+if (new_opts) + goto error_out;
Missing "!"?
Jeff
Quoted 6 lines · Jeff Epler
fs/afs/super.c static struct dentry *afs_mount(struct file_system_type *fs_type, · line 368
Quoted 2 lines · Sanidhya Kashyap
fs/afs/super.c +2
-0+if (new_opts) + goto error_out;Missing "!"?
Ohh! Sorry, missed it!
Resending the patch?
Thanks,
Sanidhya
Quoted 1 line
Jeff
PATCH 1/1 afs: kstrdup() memory handling
In reply to Sanidhya KashyapHandling kstrdup() failure in case of memory pressure even for new_opts.
Signed-off-by Sanidhya Kashyap <[email protected]>
--- fs/afs/super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/afs/super.c +5 -1
@@ -360,10 +360,13 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,struct key *key;char *new_opts =kstrdup (options,GFP_KERNEL );struct afs_super_info *as; -int ret; +int ret = -ENOMEM ;_enter (",,%s,%p" , dev_name, options); +if (!new_opts) + goto error_out; +memset (¶ms,0 ,sizeof (params)); ret = -EINVAL ;
@@ -441,6 +444,7 @@ error:afs_put_cell (params.cell);key_put (params.key);kfree (new_opts); +error_out:_leave (" = %d" , ret);return ERR_PTR (ret); }
Signature · 1 line
2.1.0
Quoted 4 lines · Sanidhya Kashyap
Handling
kstrdup()failure in case of memory pressure even fornew_opts.Signed-off-by Sanidhya Kashyap <[email protected]>
Reviewed-by Jeff Epler <[email protected]>
Quoted 40 lines
--- fs/afs/super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/afs/super.c +5
-1@@ -360,10 +360,13 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,struct key *key;char *new_opts =kstrdup (options,GFP_KERNEL );struct afs_super_info *as; -int ret; +int ret = -ENOMEM ;_enter (",,%s,%p" , dev_name, options); +if (!new_opts) + goto error_out; +memset (¶ms,0 ,sizeof (params)); ret = -EINVAL ;@@ -441,6 +444,7 @@ error:afs_put_cell (params.cell);key_put (params.key);kfree (new_opts); +error_out:_leave (" = %d" , ret);return ERR_PTR (ret); }Signature · 7 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/