Patchwork ext4: Fix a build warning in __ext4_journalled_writepage.

login
register
mail settings
Submitter Tao Ma
Date Dec. 4, 2012, 1:39 p.m.
Message ID <1354628379-3047-1-git-send-email-tm@tao.ma>
Download mbox | patch
Permalink /patch/203634/
State Superseded
Headers show

Comments

Tao Ma - Dec. 4, 2012, 1:39 p.m.
From: Tao Ma <boyu.mt@taobao.com>

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>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 fs/ext4/inode.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

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);