Re: [PATCH v2] ext4: missing !bh check in ext4_xattr_inode_write()
From: Theodore Y. Ts'o
Date: Thu Nov 08 2018 - 09:54:34 EST
On Thu, Nov 08, 2018 at 09:46:30AM +0300, Vasily Averin wrote:
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 0b9688683526..415f73d4c9e6 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1384,6 +1384,12 @@ static int ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
> bh = ext4_getblk(handle, ea_inode, block, 0);
> if (IS_ERR(bh))
> return PTR_ERR(bh);
> + if (!bh) {
> + WARN_ON_ONCE(1);
> + __ext4_error_inode(ea_inode, __func__, __LINE__, 0,
> + "ext4_getblk() return bh = NULL");
You should use EXT4_ERROR_INODE(), defined in ext4.h, not
__ext4_error_inode(). That way you don't need to explicitly specify
__func__ and __LINE__, and we the compiler will correctly do printf
format checking even when CONFIG_PRINTK is not set.
- Ted