aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_mru_cache.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index 4aff56395732..4aa316644721 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -443,6 +443,7 @@ xfs_mru_cache_insert(
443 void *value) 443 void *value)
444{ 444{
445 xfs_mru_cache_elem_t *elem; 445 xfs_mru_cache_elem_t *elem;
446 int error;
446 447
447 ASSERT(mru && mru->lists); 448 ASSERT(mru && mru->lists);
448 if (!mru || !mru->lists) 449 if (!mru || !mru->lists)
@@ -453,8 +454,8 @@ xfs_mru_cache_insert(
453 return ENOMEM; 454 return ENOMEM;
454 455
455 if (radix_tree_preload(GFP_KERNEL)) { 456 if (radix_tree_preload(GFP_KERNEL)) {
456 kmem_zone_free(xfs_mru_elem_zone, elem); 457 error = ENOMEM;
457 return ENOMEM; 458 goto out_free_item;
458 } 459 }
459 460
460 INIT_LIST_HEAD(&elem->list_node); 461 INIT_LIST_HEAD(&elem->list_node);
@@ -463,13 +464,20 @@ xfs_mru_cache_insert(
463 464
464 spin_lock(&mru->lock); 465 spin_lock(&mru->lock);
465 466
466 radix_tree_insert(&mru->store, key, elem); 467 error = -radix_tree_insert(&mru->store, key, elem);
467 radix_tree_preload_end(); 468 radix_tree_preload_end();
469 if (error) {
470 spin_unlock(&mru->lock);
471 goto out_free_item;
472 }
468 _xfs_mru_cache_list_insert(mru, elem); 473 _xfs_mru_cache_list_insert(mru, elem);
469 474
470 spin_unlock(&mru->lock); 475 spin_unlock(&mru->lock);
471 476
472 return 0; 477 return 0;
478out_free_item:
479 kmem_zone_free(xfs_mru_elem_zone, elem);
480 return error;
473} 481}
474 482
475/* 483/*