Commit 33db9fd4 authored by Javier González's avatar Javier González Committed by Jens Axboe

lightnvm: pblk: fix memory leak on error path

When write recovery fails, Free memory for the recovery structure.

Fixes: a4bd217b "lightnvm: physical block device (pblk) target"
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Reviewed-by: default avatarMatias Bjørling <matias@cnexlabs.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent f3236cef
...@@ -142,6 +142,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd) ...@@ -142,6 +142,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
/* Logic error */ /* Logic error */
if (bit > c_ctx->nr_valid) { if (bit > c_ctx->nr_valid) {
WARN_ONCE(1, "pblk: corrupted write request\n"); WARN_ONCE(1, "pblk: corrupted write request\n");
mempool_free(recovery, pblk->rec_pool);
goto out; goto out;
} }
...@@ -149,6 +150,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd) ...@@ -149,6 +150,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
entry = pblk_rb_sync_scan_entry(&pblk->rwb, &ppa); entry = pblk_rb_sync_scan_entry(&pblk->rwb, &ppa);
if (!entry) { if (!entry) {
pr_err("pblk: could not scan entry on write failure\n"); pr_err("pblk: could not scan entry on write failure\n");
mempool_free(recovery, pblk->rec_pool);
goto out; goto out;
} }
...@@ -162,6 +164,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd) ...@@ -162,6 +164,7 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
ret = pblk_recov_setup_rq(pblk, c_ctx, recovery, comp_bits, c_entries); ret = pblk_recov_setup_rq(pblk, c_ctx, recovery, comp_bits, c_entries);
if (ret) { if (ret) {
pr_err("pblk: could not recover from write failure\n"); pr_err("pblk: could not recover from write failure\n");
mempool_free(recovery, pblk->rec_pool);
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment