* [PATCH] afs: kstrdup() memory handling
@ 2015-03-21 16:50 Sanidhya Kashyap
2015-03-21 17:07 ` Jeff Epler
2015-03-21 17:13 ` Sanidhya Kashyap
0 siblings, 2 replies; 5+ messages in thread
From: Sanidhya Kashyap @ 2015-03-21 16:50 UTC (permalink / raw)
To: dhowells, linux-fsdevel, linux-kernel
Cc: taesoo, changwoo, sanidhya, blee, Sanidhya Kashyap
Handling kstrdup() failure in case of memory pressure even
for new_opts.
Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
---
fs/afs/super.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/afs/super.c b/fs/afs/super.c
index c486155..477f38e 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -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);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] afs: kstrdup() memory handling
2015-03-21 16:50 [PATCH] afs: kstrdup() memory handling Sanidhya Kashyap
@ 2015-03-21 17:07 ` Jeff Epler
2015-03-21 17:11 ` Sanidhya Kashyap
2015-03-21 17:13 ` Sanidhya Kashyap
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Epler @ 2015-03-21 17:07 UTC (permalink / raw)
To: Sanidhya Kashyap
Cc: dhowells, linux-fsdevel, linux-kernel, taesoo, changwoo, sanidhya, blee
On Sat, Mar 21, 2015 at 12:50:09PM -0400, Sanidhya Kashyap wrote:
> + if (new_opts)
> + goto error_out;
Missing "!"?
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] afs: kstrdup() memory handling
2015-03-21 17:07 ` Jeff Epler
@ 2015-03-21 17:11 ` Sanidhya Kashyap
0 siblings, 0 replies; 5+ messages in thread
From: Sanidhya Kashyap @ 2015-03-21 17:11 UTC (permalink / raw)
To: Jeff Epler
Cc: dhowells, linux-fsdevel, linux-kernel, taesoo, changwoo, Kashyap,
Sanidhya, blee
On Sat, Mar 21, 2015 at 1:07 PM, Jeff Epler <jepler@unpythonic.net> wrote:
> On Sat, Mar 21, 2015 at 12:50:09PM -0400, Sanidhya Kashyap wrote:
>> + if (new_opts)
>> + goto error_out;
>
> Missing "!"?
>
Ohh! Sorry, missed it!
Resending the patch?
Thanks,
Sanidhya
> Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] afs: kstrdup() memory handling
2015-03-21 16:50 [PATCH] afs: kstrdup() memory handling Sanidhya Kashyap
2015-03-21 17:07 ` Jeff Epler
@ 2015-03-21 17:13 ` Sanidhya Kashyap
2015-03-21 21:02 ` Jeff Epler
1 sibling, 1 reply; 5+ messages in thread
From: Sanidhya Kashyap @ 2015-03-21 17:13 UTC (permalink / raw)
To: dhowells, linux-fsdevel, linux-kernel
Cc: taesoo, changwoo, sanidhya, blee, Sanidhya Kashyap
Handling kstrdup() failure in case of memory pressure even
for new_opts.
Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
---
fs/afs/super.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/afs/super.c b/fs/afs/super.c
index c486155..477f38e 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -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);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] afs: kstrdup() memory handling
2015-03-21 17:13 ` Sanidhya Kashyap
@ 2015-03-21 21:02 ` Jeff Epler
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Epler @ 2015-03-21 21:02 UTC (permalink / raw)
To: Sanidhya Kashyap
Cc: dhowells, linux-fsdevel, linux-kernel, taesoo, changwoo, sanidhya, blee
On Sat, Mar 21, 2015 at 01:13:59PM -0400, Sanidhya Kashyap wrote:
> Handling kstrdup() failure in case of memory pressure even
> for new_opts.
>
> Signed-off-by: Sanidhya Kashyap <sanidhya.gatech@gmail.com>
Reviewed-by: Jeff Epler <jepler@unpythonic.net>
> ---
> fs/afs/super.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/afs/super.c b/fs/afs/super.c
> index c486155..477f38e 100644
> --- a/fs/afs/super.c
> +++ b/fs/afs/super.c
> @@ -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);
> }
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-21 21:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-21 16:50 [PATCH] afs: kstrdup() memory handling Sanidhya Kashyap
2015-03-21 17:07 ` Jeff Epler
2015-03-21 17:11 ` Sanidhya Kashyap
2015-03-21 17:13 ` Sanidhya Kashyap
2015-03-21 21:02 ` Jeff Epler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.