ext[2-4]: replace kmalloc+memset with kzalloc
Subsystems (2)
PATCH 1/1 ext[2-4]: replace kmalloc+memset with kzalloc
Replace kmalloc+memset with kzalloc
Signed-off-by Yan Burman <[email protected]>
fs/ext2/super.c +1 -2
@@ -883,13 +883,12 @@ static int ext2_fill_super(struct super_ goto failed_mount; }bgl_lock_init (&sbi->s_blockgroup_lock); - sbi->s_debts =kmalloc (sbi->s_groups_count *sizeof (*sbi->s_debts), + sbi->s_debts =kcalloc (sbi->s_groups_count,sizeof (*sbi->s_debts),GFP_KERNEL );if (!sbi->s_debts) {printk ("EXT2-fs: not enough memory\n" ); goto failed_mount_group_desc; } -memset (sbi->s_debts,0 , sbi->s_groups_count *sizeof (*sbi->s_debts));for (i =0 ; i < db_count; i++) { block =descriptor_loc (sb, logic_sb_block, i); sbi->s_group_desc[i] =sb_bread (sb, block);
fs/ext3/xattr.c +1 -2
@@ -733,12 +733,11 @@ ext3_xattr_block_set(handle_t *handle, s } }else {/* Allocate a buffer where we construct the new block. */ - s->base =kmalloc (sb->s_blocksize,GFP_KERNEL ); + s->base =kzalloc (sb->s_blocksize,GFP_KERNEL );/* assert(header == s->base) */ error = -ENOMEM ;if (s->base ==NULL ) goto cleanup; -memset (s->base,0 , sb->s_blocksize);header (s->base)->h_magic =cpu_to_le32 (EXT3_XATTR_MAGIC );header (s->base)->h_blocks =cpu_to_le32 (1 );header (s->base)->h_refcount =cpu_to_le32 (1 );
fs/ext4/extents.c +2 -4
@@ -641,10 +641,9 @@ static int ext4_ext_split(handle_t *hand* We need this to handle errors and free blocks * upon them. */ - ablocks =kmalloc (sizeof (ext4_fsblk_t) * depth,GFP_NOFS ); + ablocks =kcalloc (depth,sizeof (ext4_fsblk_t),GFP_NOFS );if (!ablocks)return -ENOMEM ; -memset (ablocks,0 ,sizeof (ext4_fsblk_t) * depth);/* allocate all needed blocks */ ext_debug ("allocate %d blocks for indexes/leaf\n" , depth - at);
@@ -1756,12 +1755,11 @@ int ext4_ext_remove_space(struct inode ** We start scanning from right side, freeing all the blocks * after i_size and walking into the tree depth-wise. */ - path =kmalloc (sizeof (struct ext4_ext_path ) * (depth +1 ),GFP_KERNEL ); + path =kcalloc (depth +1 ,sizeof (struct ext4_ext_path ),GFP_KERNEL );if (path ==NULL ) {ext4_journal_stop (handle);return -ENOMEM ; } -memset (path,0 ,sizeof (struct ext4_ext_path ) * (depth +1 )); path[0 ].p_hdr =ext_inode_hdr (inode);if (ext4_ext_check_header (__FUNCTION__, inode, path[0 ].p_hdr)) { err = -EIO ;
fs/ext4/xattr.c +1 -2
@@ -733,12 +733,11 @@ ext4_xattr_block_set(handle_t *handle, s } }else {/* Allocate a buffer where we construct the new block. */ - s->base =kmalloc (sb->s_blocksize,GFP_KERNEL ); + s->base =kzalloc (sb->s_blocksize,GFP_KERNEL );/* assert(header == s->base) */ error = -ENOMEM ;if (s->base ==NULL ) goto cleanup; -memset (s->base,0 , sb->s_blocksize);header (s->base)->h_magic =cpu_to_le32 (EXT4_XATTR_MAGIC );header (s->base)->h_blocks =cpu_to_le32 (1 );header (s->base)->h_refcount =cpu_to_le32 (1 );