The __GFP_NOFAIL flag ensures that allocation will not fail. So remove the unnecessary checks. Signed-off-by: Julian Sun <sunjunchao2870@xxxxxxxxx> --- fs/xfs/libxfs/xfs_da_btree.c | 4 ---- fs/xfs/libxfs/xfs_dir2.c | 8 -------- fs/xfs/xfs_buf.c | 4 ---- fs/xfs/xfs_mru_cache.c | 6 ------ fs/xfs/xfs_super.c | 2 -- 5 files changed, 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 17d9e6154f19..d4c6ad6be5e1 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2718,10 +2718,6 @@ xfs_dabuf_map( if (nirecs > 1) { map = kzalloc(nirecs * sizeof(struct xfs_buf_map), GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); - if (!map) { - error = -ENOMEM; - goto out_free_irecs; - } *mapp = map; } diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 1775abcfa04d..7d837510dc3b 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -249,8 +249,6 @@ xfs_dir_init( return error; args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); - if (!args) - return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; args->dp = dp; @@ -342,8 +340,6 @@ xfs_dir_createname( } args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); - if (!args) - return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; args->name = name->name; @@ -504,8 +500,6 @@ xfs_dir_removename( XFS_STATS_INC(dp->i_mount, xs_dir_remove); args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); - if (!args) - return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; args->name = name->name; @@ -564,8 +558,6 @@ xfs_dir_replace( return rval; args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); - if (!args) - return -ENOMEM; args->geo = dp->i_mount->m_dir_geo; args->name = name->name; diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 15bb790359f8..4b53dde32689 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -182,8 +182,6 @@ xfs_buf_get_maps( bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map), GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); - if (!bp->b_maps) - return -ENOMEM; return 0; } @@ -326,8 +324,6 @@ xfs_buf_alloc_kmem( gfp_mask |= __GFP_ZERO; bp->b_addr = kmalloc(size, gfp_mask); - if (!bp->b_addr) - return -ENOMEM; if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) != ((unsigned long)bp->b_addr & PAGE_MASK)) { diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c index d0f5b403bdbe..0d08d6b5e5be 100644 --- a/fs/xfs/xfs_mru_cache.c +++ b/fs/xfs/xfs_mru_cache.c @@ -333,17 +333,11 @@ xfs_mru_cache_create( return -EINVAL; mru = kzalloc(sizeof(*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) { - err = -ENOMEM; - goto exit; - } for (grp = 0; grp < mru->grp_count; grp++) INIT_LIST_HEAD(mru->lists + grp); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0055066fb1d9..59a600d8de7c 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -2075,8 +2075,6 @@ xfs_init_fs_context( int i; mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL | __GFP_NOFAIL); - if (!mp) - return -ENOMEM; spin_lock_init(&mp->m_sb_lock); for (i = 0; i < XG_TYPE_MAX; i++) -- 2.39.5