Return from yaffs_internal_read_super if kmalloc fail
authorKjetil Aamodt <kjeaamod@cisco.com>
Mon, 9 Sep 2013 13:24:52 +0000 (15:24 +0200)
committerCharles Manning <cdhmanning@gmail.com>
Tue, 21 Jan 2014 23:27:28 +0000 (12:27 +1300)
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

index 67050d4..27cc0c0 100644 (file)
@@ -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."