xfs: remove dead NULL check after __GFP_NOFAIL allocation
PATCH 1/1 xfs: remove dead NULL check after __GFP_NOFAIL allocation
kmalloc with the __GFP_NOFAIL flag will never return NULL, so the subsequent ENOMEM check is unreachable dead code. Remove it.
Signed-off-by Gou Hao <[email protected]>
--- fs/xfs/libxfs/xfs_dir2.c | 12 ------------ fs/xfs/libxfs/xfs_exchmaps.c | 5 ----- fs/xfs/xfs_buf.c | 3 --- fs/xfs/xfs_mru_cache.c | 8 -------- 4 files changed, 28 deletions(-)
fs/xfs/libxfs/xfs_dir2.c +0 -12
@@ -249,9 +249,6 @@ xfs_dir_init(return error; args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->dp = dp; args->trans = tp;
@@ -342,9 +339,6 @@ xfs_dir_createname( } args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;
@@ -503,9 +497,6 @@ xfs_dir_removename(XFS_STATS_INC (dp->i_mount, xs_dir_remove); args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;
@@ -563,9 +554,6 @@ xfs_dir_replace(return rval; args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;
fs/xfs/libxfs/xfs_exchmaps.c +0 -5
@@ -500,11 +500,6 @@ xfs_exchmaps_link_to_sf(/* Read the current symlink target into a buffer. */ buf =kmalloc (ip->i_disk_size +1 ,GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); -if (!buf) { -ASSERT (0 ); -return -ENOMEM ; - } - error =xfs_symlink_remote_read (ip, buf);if (error) goto free;
fs/xfs/xfs_buf.c +0 -3
@@ -130,9 +130,6 @@ xfs_buf_alloc_kmem(ASSERT (size <PAGE_SIZE ); bp->b_addr =kmalloc (size, gfp_mask | __GFP_NOFAIL); -if (!bp->b_addr) -return -ENOMEM ; -/* * Slab guarantees that we get back naturally aligned allocations for * power of two sizes. Keep this check as the canary in the coal mine
fs/xfs/xfs_mru_cache.c +0 -8
@@ -334,18 +334,10 @@ xfs_mru_cache_create(return -EINVAL ; mru =kzalloc_obj (*mru,GFP_KERNEL | __GFP_NOFAIL); -if (!mru) -return -ENOMEM ; -/* An extra list is needed to avoid reaping up to a grp_time early. */ mru->grp_count = grp_count +1 ; mru->lists =kzalloc (mru->grp_count *sizeof (*mru->lists),GFP_KERNEL | __GFP_NOFAIL); -if (!mru->lists) { -kfree (mru); -return -ENOMEM ; - } -for (grp =0 ; grp < mru->grp_count; grp++)INIT_LIST_HEAD (mru->lists + grp);
Signature · 1 line
2.20.1
Quoted 4 lines · Gou Hao
kmalloc with the
__GFP_NOFAILflag will never return NULL, so the subsequent ENOMEM check is unreachable dead code. Remove it.Signed-off-by Gou Hao <[email protected]>
Looks fine.
Reviewed-by Carlos Maiolino <[email protected]>
Quoted 108 lines
--- fs/xfs/libxfs/xfs_dir2.c | 12 ------------ fs/xfs/libxfs/xfs_exchmaps.c | 5 ----- fs/xfs/xfs_buf.c | 3 --- fs/xfs/xfs_mru_cache.c | 8 -------- 4 files changed, 28 deletions(-)fs/xfs/libxfs/xfs_dir2.c +0
-12@@ -249,9 +249,6 @@ xfs_dir_init(return error; args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->dp = dp; args->trans = tp;@@ -342,9 +339,6 @@ xfs_dir_createname( } args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;@@ -503,9 +497,6 @@ xfs_dir_removename(XFS_STATS_INC (dp->i_mount, xs_dir_remove); args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;@@ -563,9 +554,6 @@ xfs_dir_replace(return rval; args =kzalloc_obj (*args,GFP_KERNEL | __GFP_NOFAIL); -if (!args) -return -ENOMEM ; - args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len;fs/xfs/libxfs/xfs_exchmaps.c +0
-5@@ -500,11 +500,6 @@ xfs_exchmaps_link_to_sf(/* Read the current symlink target into a buffer. */ buf =kmalloc (ip->i_disk_size +1 ,GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); -if (!buf) { -ASSERT (0 ); -return -ENOMEM ; - } - error =xfs_symlink_remote_read (ip, buf);if (error) goto free;fs/xfs/xfs_buf.c +0
-3@@ -130,9 +130,6 @@ xfs_buf_alloc_kmem(ASSERT (size <PAGE_SIZE ); bp->b_addr =kmalloc (size, gfp_mask | __GFP_NOFAIL); -if (!bp->b_addr) -return -ENOMEM ; -/* * Slab guarantees that we get back naturally aligned allocations for * power of two sizes. Keep this check as the canary in the coal mine fs/xfs/xfs_mru_cache.c +0
-8@@ -334,18 +334,10 @@ xfs_mru_cache_create(return -EINVAL ; mru =kzalloc_obj (*mru,GFP_KERNEL | __GFP_NOFAIL); -if (!mru) -return -ENOMEM ; -/* An extra list is needed to avoid reaping up to a grp_time early. */ mru->grp_count = grp_count +1 ; mru->lists =kzalloc (mru->grp_count *sizeof (*mru->lists),GFP_KERNEL | __GFP_NOFAIL); -if (!mru->lists) { -kfree (mru); -return -ENOMEM ; - } -for (grp =0 ; grp < mru->grp_count; grp++)INIT_LIST_HEAD (mru->lists + grp);Signature · 1 line
2.20.1