Skip to content

Commit

Permalink
lightnvm: pblk: fix memory leak on error path
Browse files Browse the repository at this point in the history
When write recovery fails, Free memory for the recovery structure.

Fixes: a4bd217 "lightnvm: physical block device (pblk) target"

Signed-off-by: Javier González <javier@cnexlabs.com>
Reviewed-by: Matias Bjørling <matias@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Javier González authored and Jens Axboe committed Apr 23, 2017
1 parent f3236ce commit 33db9fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/lightnvm/pblk-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@ static void pblk_end_w_fail(struct pblk *pblk, struct nvm_rq *rqd)
/* Logic error */
if (bit > c_ctx->nr_valid) {
WARN_ONCE(1, "pblk: corrupted write request\n");
mempool_free(recovery, pblk->rec_pool);
goto out;
}

ppa = ppa_list[bit];
entry = pblk_rb_sync_scan_entry(&pblk->rwb, &ppa);
if (!entry) {
pr_err("pblk: could not scan entry on write failure\n");
mempool_free(recovery, pblk->rec_pool);
goto out;
}

Expand All @@ -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);
if (ret) {
pr_err("pblk: could not recover from write failure\n");
mempool_free(recovery, pblk->rec_pool);
goto out;
}

Expand Down

0 comments on commit 33db9fd

Please sign in to comment.