diff mbox

[ext4:dev,40/60] fs/ext4/inode.c:1953 __ext4_journalled_writepage() error: potential NULL dereference 'page_bufs'.

Message ID 1354627545-2792-1-git-send-email-tm@tao.ma
State Superseded, archived
Headers show

Commit Message

Tao Ma Dec. 4, 2012, 1:25 p.m. UTC
Hi Dan,
	Thanks for the report. Can you check whether this patch
works for you?

Thanks
Tao

From: Tao Ma <boyu.mt@taobao.com>
Subject: [PATCH] ext4: Fix a build warning in __ext4_journalled_writepage.

smatch complains:
fs/ext4/inode.c:1953 __ext4_journalled_writepage() error: potential NULL dereference 'page_bufs'.

So add the check for it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/ext4/inode.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Comments

Dan Carpenter Dec. 4, 2012, 1:56 p.m. UTC | #1
On Tue, Dec 04, 2012 at 09:25:45PM +0800, Tao Ma wrote:
> Hi Dan,
> 	Thanks for the report. Can you check whether this patch
> works for you?
> 

It looks good.

Like I mentioned before Smatch doesn't understand
ext4_has_inline_data() so it still complains later on in the
function.  But it's now obvious to a human reader that there won't
be a NULL dereference.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index dbc5784..431201b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1956,7 +1956,7 @@  static int __ext4_journalled_writepage(struct page *page,
 	struct buffer_head *page_bufs = NULL;
 	handle_t *handle = NULL;
 	int ret = 0;
-	int err;
+	int err = 0;
 	struct buffer_head *inode_bh = NULL;
 
 	ClearPageChecked(page);
@@ -1987,8 +1987,7 @@  static int __ext4_journalled_writepage(struct page *page,
 		ret = ext4_journal_get_write_access(handle, inode_bh);
 
 		err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
-
-	} else {
+	} else if (page_bufs) {
 		ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
 					     do_journal_get_write_access);