From patchwork Sun Aug 19 08:44:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [13/14] drivers/mtd/ubi/build.c: fix error return code Date: Sat, 18 Aug 2012 22:44:29 -0000 From: Julia Lawall X-Patchwork-Id: 178549 Message-Id: <1345365870-29831-14-git-send-email-Julia.Lawall@lip6.fr> To: Artem Bityutskiy Cc: David Woodhouse , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org From: Julia Lawall Initialize return variable before exiting on an error path. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // Signed-off-by: Julia Lawall --- drivers/mtd/ubi/build.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 7b6b5f9..afe9075 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1159,8 +1159,10 @@ static int __init ubi_init(void) ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab", sizeof(struct ubi_wl_entry), 0, 0, NULL); - if (!ubi_wl_entry_slab) + if (!ubi_wl_entry_slab) { + err = -ENOMEM; goto out_dev_unreg; + } err = ubi_debugfs_init(); if (err)