From e72372f93c862b499f586006cd30a5052fde38f8 Mon Sep 17 00:00:00 2001 From: Kjetil Aamodt Date: Mon, 9 Sep 2013 15:24:52 +0200 Subject: [PATCH] Return from yaffs_internal_read_super if kmalloc fail Return if either, or both, of dev and context failed to kmalloc(). kfree() handles NULL as argument so utilise that to simplify code. --- yaffs_vfs_multi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index 67050d4..27cc0c0 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -2713,15 +2713,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, context = kmalloc(sizeof(struct yaffs_linux_context), GFP_KERNEL); if (!dev || !context) { - if (dev) - kfree(dev); - if (context) - kfree(context); + kfree(dev); + kfree(context); dev = NULL; context = NULL; - } - if (!dev) { /* Deep shit could not allocate device structure */ yaffs_trace(YAFFS_TRACE_ALWAYS, "yaffs_read_super: Failed trying to allocate struct yaffs_dev." -- 2.30.2