Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752899AbbCXWjb (ORCPT ); Tue, 24 Mar 2015 18:39:31 -0400 Received: from mx2.gtisc.gatech.edu ([143.215.130.82]:57348 "EHLO mx2.gtisc.gatech.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbbCXWj3 (ORCPT ); Tue, 24 Mar 2015 18:39:29 -0400 From: Chengyu Song To: joern@logfs.org, prasadjoshi.linux@gmail.com, logfs@logfs.org, linux-kernel@vger.kernel.org Cc: taesoo@gatech.edu, changwoo@gatech.edu, sanidhya@gatech.edu, blee@gatech.edu, csong84@gatech.edu Subject: [PATCH 1/1] logfs: incorrect check for read_cache_page return Date: Tue, 24 Mar 2015 18:35:53 -0400 Message-Id: <1427236553-8247-1-git-send-email-csong84@gatech.edu> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org read_cache_page returns -EIO on error, so the return should be checked against ERROR_VALUE instead of NULL. Signed-off-by: Chengyu Song --- 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