From: Youling Tang Date: Tue, 16 Jul 2024 02:58:16 +0000 (+0800) Subject: bcachefs: allocate inode by using alloc_inode_sb() X-Git-Tag: v6.12-rc1~6^2~116 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=082330c361944a234db42750792b491f3b76d43b;p=linux-block.git bcachefs: allocate inode by using alloc_inode_sb() The inode allocation is supposed to use alloc_inode_sb(), so convert kmem_cache_alloc() to alloc_inode_sb(). It will also fix [1] to avoid the NULL pointer dereference BUG in list_lru_add() when CONFIG_MEMCG is enabled. Links: [1]: https://lore.kernel.org/all/20589721-46c0-4344-b2ef-6ab48bbe2ea5@linux.dev/ [2]: https://lore.kernel.org/all/7db60e36-9c96-4938-a28d-a9745e287386@linux.dev/ Fixes: 86d81ec5f5f0 ("bcachefs: Mark bch_inode_info as SLAB_ACCOUNT") Signed-off-by: Youling Tang Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 2505daaec458..cb71d05a32bc 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -293,7 +293,8 @@ static struct inode *bch2_alloc_inode(struct super_block *sb) static struct bch_inode_info *__bch2_new_inode(struct bch_fs *c) { - struct bch_inode_info *inode = kmem_cache_alloc(bch2_inode_cache, GFP_NOFS); + struct bch_inode_info *inode = alloc_inode_sb(c->vfs_sb, + bch2_inode_cache, GFP_NOFS); if (!inode) return NULL;