mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/5] ubifs: check return pointer properly
Date: Wed,  6 Jul 2016 21:32:52 +0200	[thread overview]
Message-ID: <1467833572-26162-5-git-send-email-dev@lynxeye.de> (raw)
In-Reply-To: <1467833572-26162-1-git-send-email-dev@lynxeye.de>

ubifs_iget() returns error codes encoded in the pointer,
so the NULL check will never be true.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 fs/ubifs/ubifs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index bc1b521..47eef7c 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -533,7 +533,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, const char *filename
 			return 0;
 		inode = ubifs_iget(sb, inum);
 
-		if (!inode)
+		if (IS_ERR(inode))
 			return 0;
 		ui = ubifs_inode(inode);
 
@@ -1001,7 +1001,7 @@ static int ubifs_open(struct device_d *dev, FILE *file, const char *filename)
 		return -ENOENT;
 
 	inode = ubifs_iget(priv->sb, inum);
-	if (!inode)
+	if (IS_ERR(inode))
 		return -ENOENT;
 
 	uf = xzalloc(sizeof(*uf));
@@ -1126,7 +1126,7 @@ static DIR *ubifs_opendir(struct device_d *dev, const char *pathname)
 		return NULL;
 
 	inode = ubifs_iget(priv->sb, inum);
-	if (!inode)
+	if (IS_ERR(inode))
 		return NULL;
 
 	ubifs_iput(inode);
@@ -1206,7 +1206,7 @@ static int ubifs_stat(struct device_d *dev, const char *filename, struct stat *s
 		return -ENOENT;
 
 	inode = ubifs_iget(priv->sb, inum);
-	if (!inode)
+	if (IS_ERR(inode))
 		return -ENOENT;
 
 	s->st_size = inode->i_size;
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-07-06 19:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 19:32 [PATCH 1/5] commands: menu: " Lucas Stach
2016-07-06 19:32 ` [PATCH 2/5] ARM: i.MX: iim: fix potential out of bounds array access Lucas Stach
2016-07-06 19:32 ` [PATCH 3/5] ubifs: fix potential memory leak Lucas Stach
2016-07-07  7:06   ` Sascha Hauer
2016-07-06 19:32 ` [PATCH 4/5] ubifs: fix potential NULL ptr dereference Lucas Stach
2016-07-07  7:15   ` Sascha Hauer
2016-07-06 19:32 ` Lucas Stach [this message]
2016-07-07  7:46 ` [PATCH 1/5] commands: menu: check return pointer properly Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467833572-26162-5-git-send-email-dev@lynxeye.de \
    --to=dev@lynxeye.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox