On Wed, 21 Dec 2022 11:21:20 +0800 XU pengfei <xupengfei@xxxxxxxxxxxx> wrote: > Variables are assigned first and then used. Initialization is not required. Looks good to me. When making such changes I suggest you also look for opportunities to narrow the scope of the affected variables. It makes the code easier to read and to review. ie, --- a/fs/hfsplus/xattr.c~hfsplus-remove-unnecessary-variable-initialization-fix +++ a/fs/hfsplus/xattr.c @@ -677,7 +677,6 @@ ssize_t hfsplus_listxattr(struct dentry ssize_t res; struct inode *inode = d_inode(dentry); struct hfs_find_data fd; - u16 key_len; struct hfsplus_attr_key attr_key; char *strbuf; int xattr_name_len; @@ -719,7 +718,8 @@ ssize_t hfsplus_listxattr(struct dentry } for (;;) { - key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset); + u16 key_len = hfs_bnode_read_u16(fd.bnode, fd.keyoffset); + if (key_len == 0 || key_len > fd.tree->max_key_len) { pr_err("invalid xattr key length: %d\n", key_len); res = -EIO; _