target: simplify target_fabric_make_lun error path
authorJoern Engel <joern@logfs.org>
Wed, 17 Sep 2014 22:11:28 +0000 (15:11 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 17 Sep 2014 22:11:28 +0000 (15:11 -0700)
Coverity complained that lun_cg has been dereferenced in all paths
leading to NULL check.  It didn't mention that only a single path could
lead there and the code can be simplified even further.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_fabric_configfs.c

index 0638a672d9117f2ec3c147966cbf7f6a03faf18a..dc6c781732ee6e375fcacccedacf39725f268c71 100644 (file)
@@ -911,15 +911,12 @@ static struct config_group *target_fabric_make_lun(
                                GFP_KERNEL);
        if (!port_stat_grp->default_groups) {
                pr_err("Unable to allocate port_stat_grp->default_groups\n");
-               errno = -ENOMEM;
-               goto out;
+               kfree(lun_cg->default_groups);
+               return ERR_PTR(-ENOMEM);
        }
        target_stat_setup_port_default_groups(lun);
 
        return &lun->lun_group;
-out:
-       kfree(lun_cg->default_groups);
-       return ERR_PTR(errno);
 }
 
 static void target_fabric_drop_lun(