lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171004082441.2405-1-juerg.haefliger@canonical.com>
Date:   Wed,  4 Oct 2017 04:24:41 -0400
From:   Juerg Haefliger <juerg.haefliger@...onical.com>
To:     shaggy@...nel.org, jfs-discussion@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org
Cc:     Juerg Haefliger <juerg.haefliger@...onical.com>
Subject: [PATCH] jfs: Add missing NULL pointer check in __get_metapage

alloc_metapage can return a NULL pointer so check for that. And also emit
an error message if that happens.

Signed-off-by: Juerg Haefliger <juerg.haefliger@...onical.com>
---
 fs/jfs/jfs_metapage.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 1c4b9ad4d7ab..00f21af66872 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -187,14 +187,18 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
 {
 	struct metapage *mp = mempool_alloc(metapage_mempool, gfp_mask);
 
-	if (mp) {
-		mp->lid = 0;
-		mp->lsn = 0;
-		mp->data = NULL;
-		mp->clsn = 0;
-		mp->log = NULL;
-		init_waitqueue_head(&mp->wait);
+	if (!mp) {
+		jfs_err("mempool_alloc failed!\n");
+		return NULL;
 	}
+
+	mp->lid = 0;
+	mp->lsn = 0;
+	mp->data = NULL;
+	mp->clsn = 0;
+	mp->log = NULL;
+	init_waitqueue_head(&mp->wait);
+
 	return mp;
 }
 
@@ -663,6 +667,8 @@ struct metapage *__get_metapage(struct inode *inode, unsigned long lblock,
 	} else {
 		INCREMENT(mpStat.pagealloc);
 		mp = alloc_metapage(GFP_NOFS);
+		if (!mp)
+			goto unlock;
 		mp->page = page;
 		mp->sb = inode->i_sb;
 		mp->flag = 0;
-- 
2.14.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ