erofs: avoid useless memory allocation
PATCH v2 1/1 erofs: avoid useless memory allocation
The variable 'vi->xattr_shared_count' could be ZERO.
Signed-off-by Noboru Asai <[email protected]>
--- fs/erofs/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
fs/erofs/xattr.c +3 -0
@@ -80,6 +80,8 @@ static int init_inode_xattrs(struct inode *inode) ih = (struct erofs_xattr_ibody_header *)(it.kaddr + it.ofs); vi->xattr_shared_count = ih->h_shared_count; +if (!vi->xattr_shared_count) + goto out_put_metabuf; vi->xattr_shared_xattrs =kmalloc_array (vi->xattr_shared_count,sizeof (uint),GFP_KERNEL );if (!vi->xattr_shared_xattrs) {
@@ -110,6 +112,7 @@ static int init_inode_xattrs(struct inode *inode)le32_to_cpu (*(__le32 *)(it.kaddr + it.ofs)); it.ofs +=sizeof (__le32); } +out_put_metabuf:erofs_put_metabuf (&it.buf);/* paired with smp_mb() at the beginning of the function. */
Signature · 1 line
2.39.2