All of lore.kernel.org
 help / color / mirror / Atom feed
* [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(&params, 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

end of thread, other threads:[~2015-03-21 21:02 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.