Skip to content

Commit 595189c

Browse files
YuKuai-huaweidjwong
authored andcommitted
xfs: return corresponding errcode if xfs_initialize_perag() fail
In xfs_initialize_perag(), if kmem_zalloc(), xfs_buf_hash_init(), or radix_tree_preload() failed, the returned value 'error' is not set accordingly. Reported-as-fixing: 8b26c58 ("xfs: handle ENOMEM correctly during initialisation of perag structures") Fixes: 9b24717 ("xfs: cache unlinked pointers in an rhashtable") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 27c14b5 commit 595189c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/xfs/xfs_mount.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,25 @@ xfs_initialize_perag(
194194
}
195195

196196
pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL);
197-
if (!pag)
197+
if (!pag) {
198+
error = -ENOMEM;
198199
goto out_unwind_new_pags;
200+
}
199201
pag->pag_agno = index;
200202
pag->pag_mount = mp;
201203
spin_lock_init(&pag->pag_ici_lock);
202204
INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
203-
if (xfs_buf_hash_init(pag))
205+
206+
error = xfs_buf_hash_init(pag);
207+
if (error)
204208
goto out_free_pag;
205209
init_waitqueue_head(&pag->pagb_wait);
206210
spin_lock_init(&pag->pagb_lock);
207211
pag->pagb_count = 0;
208212
pag->pagb_tree = RB_ROOT;
209213

210-
if (radix_tree_preload(GFP_NOFS))
214+
error = radix_tree_preload(GFP_NOFS);
215+
if (error)
211216
goto out_hash_destroy;
212217

213218
spin_lock(&mp->m_perag_lock);

0 commit comments

Comments
 (0)