hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9935 -------------------------------- During dpool init dpool_global_pool is inited before fill_pool which will init pfn_ranges. However in page_in_dynamic_pool, pfn_ranges will be accessed if dpool_global_pool is set, which will lead to NULL pointer dereference. Fixes this issue by moving dpool_global_pool init to the end of dpool_init. Fixes: cf98ffbc116b ("mm/dynamic_pool: fill dpool with pagelist") Signed-off-by: Wupeng Ma <mawupeng1@huawei.com> --- mm/dynamic_pool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/dynamic_pool.c b/mm/dynamic_pool.c index b9249a1c5d20a..cc553982d85f2 100644 --- a/mm/dynamic_pool.c +++ b/mm/dynamic_pool.c @@ -1710,12 +1710,13 @@ int dpool_init(struct dpool_info *arg) goto unlock; } - dpool_global_pool = dpool; - BUG_ON(!dpool->ops->fill_pool); ret = dpool->ops->fill_pool(dpool, arg); if (ret) dpool_put(dpool); + else + /* make dpool_global_pool visible iff dpool init succeed */ + dpool_global_pool = dpool; unlock: mutex_unlock(&dpool_mutex); -- 2.43.0