Skip to content

Commit 19fa6e4

Browse files
elfringcmaiolino
authored andcommitted
xfs: Improve error handling in xfs_mru_cache_create()
Simplify error handling in this function implementation. * Delete unnecessary pointer checks and variable assignments. * Omit a redundant function call. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 0989dfa commit 19fa6e4

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

fs/xfs/xfs_mru_cache.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ xfs_mru_cache_create(
320320
xfs_mru_cache_free_func_t free_func)
321321
{
322322
struct xfs_mru_cache *mru = NULL;
323-
int err = 0, grp;
323+
int grp;
324324
unsigned int grp_time;
325325

326326
if (mrup)
@@ -341,8 +341,8 @@ xfs_mru_cache_create(
341341
mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
342342
GFP_KERNEL | __GFP_NOFAIL);
343343
if (!mru->lists) {
344-
err = -ENOMEM;
345-
goto exit;
344+
kfree(mru);
345+
return -ENOMEM;
346346
}
347347

348348
for (grp = 0; grp < mru->grp_count; grp++)
@@ -361,14 +361,7 @@ xfs_mru_cache_create(
361361
mru->free_func = free_func;
362362
mru->data = data;
363363
*mrup = mru;
364-
365-
exit:
366-
if (err && mru && mru->lists)
367-
kfree(mru->lists);
368-
if (err && mru)
369-
kfree(mru);
370-
371-
return err;
364+
return 0;
372365
}
373366

374367
/*

0 commit comments

Comments
 (0)