ext4: fix bh ref count on error paths
authorZhaolong Zhang <zhangzl2013@126.com>
Tue, 2 Mar 2021 09:42:31 +0000 (17:42 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 6 Mar 2021 16:56:11 +0000 (11:56 -0500)
__ext4_journalled_writepage should drop bhs' ref count on error paths

Signed-off-by: Zhaolong Zhang <zhangzl2013@126.com>
Link: https://lore.kernel.org/r/1614678151-70481-1-git-send-email-zhangzl2013@126.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/inode.c

index 650c5acd2f2d99765622b5490b6e915e1c7aabbf..a79a9ea58c568051823e9324519db9c9b384c3af 100644 (file)
@@ -1938,13 +1938,13 @@ static int __ext4_journalled_writepage(struct page *page,
        if (!ret)
                ret = err;
 
-       if (!ext4_has_inline_data(inode))
-               ext4_walk_page_buffers(NULL, page_bufs, 0, len,
-                                      NULL, bput_one);
        ext4_set_inode_state(inode, EXT4_STATE_JDATA);
 out:
        unlock_page(page);
 out_no_pagelock:
+       if (!inline_data && page_bufs)
+               ext4_walk_page_buffers(NULL, page_bufs, 0, len,
+                                      NULL, bput_one);
        brelse(inode_bh);
        return ret;
 }