Skip to contentSkip to conversation

logfs: incorrect check for read_cache_page return

PATCH New Chengyu Song 1 participant 1 message Mar 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 logfs: incorrect check for read_cache_page return

read_cache_page returns -EIO on error, so the return should be checked against ERROR_VALUE instead of NULL.

---
 fs/logfs/segment.c | 4 ++--
 fs/logfs/super.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/logfs/segment.c +2 -2
index 7f9b096..2e5d45b 100644
@@ -113,7 +113,7 @@ static void pad_partial_page(struct logfs_area *area)
 
 	if (len % PAGE_SIZE) {
 		page = get_mapping_page(sb, index, 0);
-		BUG_ON(!page); /* FIXME: reserve a pool */
+		BUG_ON(IS_ERR(page)); /* FIXME: reserve a pool */
 		memset(page_address(page) + offset, 0xff, len);
 		if (!PagePrivate(page)) {
 			SetPagePrivate(page);
@@ -135,7 +135,7 @@ static void pad_full_pages(struct logfs_area *area)
 
 	while (no_indizes) {
 		page = get_mapping_page(sb, index, 0);
-		BUG_ON(!page); /* FIXME: reserve a pool */
+		BUG_ON(IS_ERR(page)); /* FIXME: reserve a pool */
 		SetPageUptodate(page);
 		memset(page_address(page), 0xff, PAGE_CACHE_SIZE);
 		if (!PagePrivate(page)) {
fs/logfs/super.c +2 -2
index 5436029..b5ea89c 100644
@@ -28,7 +28,7 @@ struct page *emergency_read_begin(struct address_space *mapping, pgoff_t index)
 	int err;
 
 	page = read_cache_page(mapping, index, filler, NULL);
-	if (page)
+	if (!IS_ERR(page))
 		return page;
 
 	/* No more pages available, switch to emergency page */
@@ -196,7 +196,7 @@ static int write_one_sb(struct super_block *sb,
 	int err;
 
 	page = find_sb(sb, &ofs);
-	if (!page)
+	if (IS_ERR(page))
 		return -EIO;
 	ds = page_address(page);
 	segno = seg_no(sb, ofs);
Signature · 1 line
2.1.0