[PATCH 1/1] logfs: incorrect check for read_cache_page return

From: Chengyu Song
Date: Tue Mar 24 2015 - 18:39:35 EST


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

Signed-off-by: Chengyu Song <csong84@xxxxxxxxxx>
---
fs/logfs/segment.c | 4 ++--
fs/logfs/super.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/logfs/segment.c b/fs/logfs/segment.c
index 7f9b096..2e5d45b 100644
--- a/fs/logfs/segment.c
+++ b/fs/logfs/segment.c
@@ -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)) {
diff --git a/fs/logfs/super.c b/fs/logfs/super.c
index 5436029..b5ea89c 100644
--- a/fs/logfs/super.c
+++ b/fs/logfs/super.c
@@ -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);
--
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/