lightnvm: pblk: fix releases of kmem cache in error path
PATCH 6/6 lightnvm: pblk: fix releases of kmem cache in error path
If pblk_core_init fails lets destroy all global caches.
--- drivers/lightnvm/pblk-init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/lightnvm/pblk-init.c +7 -1
@@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk) pblk->page_bio_pool =mempool_create_page_pool (nvm_max_phys_sects (dev),0 );if (!pblk->page_bio_pool) -return -ENOMEM ; + goto free_global_caches; pblk->gen_ws_pool =mempool_create_slab_pool (PBLK_GEN_WS_POOL_SIZE , pblk_ws_cache);
@@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)mempool_destroy (pblk->gen_ws_pool); free_page_bio_pool:mempool_destroy (pblk->page_bio_pool); +free_global_caches: +kmem_cache_destroy (pblk_ws_cache); +kmem_cache_destroy (pblk_rec_cache); +kmem_cache_destroy (pblk_g_rq_cache); +kmem_cache_destroy (pblk_e_rq_cache); +kmem_cache_destroy (pblk_w_rq_cache);return -ENOMEM ; }
Signature · 1 line
2.7.4
Quoted 35 lines · Rakesh Pandit
If
pblk_core_initfails lets destroy all global caches.Signed-off-by Rakesh Pandit <[email protected]>---
drivers/lightnvm/pblk-init.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/lightnvm/pblk-init.c +1
-1@@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk) pblk->page_bio_pool =mempool_create_page_pool (nvm_max_phys_sects (dev),0 );if (!pblk->page_bio_pool) -return -ENOMEM ; + goto free_global_caches; pblk->gen_ws_pool =mempool_create_slab_pool (PBLK_GEN_WS_POOL_SIZE , pblk_ws_cache);@@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)mempool_destroy (pblk->gen_ws_pool);
free_page_bio_pool:mempool_destroy(pblk->page_bio_pool);drivers/lightnvm/pblk-init.c +6
-0+free_global_caches: +kmem_cache_destroy (pblk_ws_cache); +kmem_cache_destroy (pblk_rec_cache); +kmem_cache_destroy (pblk_g_rq_cache); +kmem_cache_destroy (pblk_e_rq_cache); +kmem_cache_destroy (pblk_w_rq_cache);return -ENOMEM; }
Quoted 2 lines
--
2.7.4
Looks good. I'll refactor it on a single function so that we can reuse it on tear down. It will also be simpler to add/remove caches in the future.
Since it depends on the last patch, I'll wait until you reply to it before making the changes.
Javier
Quoted 42 lines · Javier Gonz�lez
Quoted 35 lines · Rakesh Pandit
If
pblk_core_initfails lets destroy all global caches.Signed-off-by Rakesh Pandit <[email protected]>---
drivers/lightnvm/pblk-init.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/lightnvm/pblk-init.c +1
-1@@ -246,7 +246,7 @@ static int pblk_core_init(struct pblk *pblk) pblk->page_bio_pool =mempool_create_page_pool (nvm_max_phys_sects (dev),0 );if (!pblk->page_bio_pool) -return -ENOMEM ; + goto free_global_caches; pblk->gen_ws_pool =mempool_create_slab_pool (PBLK_GEN_WS_POOL_SIZE , pblk_ws_cache);@@ -314,6 +314,12 @@ static int pblk_core_init(struct pblk *pblk)mempool_destroy (pblk->gen_ws_pool);
free_page_bio_pool:mempool_destroy(pblk->page_bio_pool);drivers/lightnvm/pblk-init.c +6
-0+free_global_caches: +kmem_cache_destroy (pblk_ws_cache); +kmem_cache_destroy (pblk_rec_cache); +kmem_cache_destroy (pblk_g_rq_cache); +kmem_cache_destroy (pblk_e_rq_cache); +kmem_cache_destroy (pblk_w_rq_cache);return -ENOMEM; }Quoted 2 lines
--
2.7.4Looks good. I'll refactor it on a single function so that we can reuse it on tear down. It will also be simpler to add/remove caches in the future.
Quoted 2 lines
Since it depends on the last patch, I'll wait until you reply to it before making the changes.
Please go ahead. Now that previous patch is can be ignored, you can adjust accordingly.
Thank you.
Quoted 2 lines
Javier