Patchwork [4/4] UBIFS: fix oops on error path in read_pnode

login
register
mail settings
Submitter Artem Bityutskiy
Date March 28, 2011, 7:38 a.m.
Message ID <1301297914-14712-4-git-send-email-dedekind1@gmail.com>
Download mbox | patch
Permalink /patch/88569/
State Accepted
Commit 54acbaaa523ca0bd284a18f67ad213c379679e86
Headers show

Comments

Artem Bityutskiy - March 28, 2011, 7:38 a.m.
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Thanks to coverity which spotted that UBIFS will oops if 'kmalloc()'
in 'read_pnode()' fails and we dereference a NULL 'pnode' pointer
when we 'goto out'.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 fs/ubifs/lpt.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

Patch

diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 72775d3..ef5155e 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1270,10 +1270,9 @@  static int read_pnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip)
 	lnum = branch->lnum;
 	offs = branch->offs;
 	pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
-	if (!pnode) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!pnode)
+		return -ENOMEM;
+
 	if (lnum == 0) {
 		/*
 		 * This pnode was not written which just means that the LEB