ext4: avoid potential buffer_head leak in __ext4_new_inode()
authorKemeng Shi <shikemeng@huaweicloud.com>
Tue, 20 Aug 2024 13:22:29 +0000 (21:22 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 4 Sep 2024 02:12:15 +0000 (22:12 -0400)
commit227d31b9214d1b9513383cf6c7180628d4b3b61f
tree993fb3ed1b934d121581c1ec47bceef224cac01e
parent5e5b2a56c57def1b41efd49596621504d7bcc61c
ext4: avoid potential buffer_head leak in __ext4_new_inode()

If a group is marked EXT4_GROUP_INFO_IBITMAP_CORRUPT after it's inode
bitmap buffer_head was successfully verified, then __ext4_new_inode()
will get a valid inode_bitmap_bh of a corrupted group from
ext4_read_inode_bitmap() in which case inode_bitmap_bh misses a release.
Hnadle "IS_ERR(inode_bitmap_bh)" and group corruption separately like
how ext4_free_inode() does to avoid buffer_head leak.

Fixes: 9008a58e5dce ("ext4: make the bitmap read routines return real error codes")
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Link: https://patch.msgid.link/20240820132234.2759926-3-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ialloc.c