]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
lightnvm: pblk: fix memory leak on error path
authorJavier González <jg@lightnvm.io>
Fri, 21 Apr 2017 23:32:47 +0000 (01:32 +0200)
committerJens Axboe <axboe@fb.com>
Sun, 23 Apr 2017 22:57:52 +0000 (16:57 -0600)
When write recovery fails, Free memory for the recovery structure.

Fixes: a4bd217b4326 "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>
drivers/lightnvm/pblk-write.c

index 74f7413a6b207628e4af4a438ac9676b85b1660f..a896190c82f09484fadf7b1f511542335f44216c 100644 (file)
@@ -142,6 +142,7 @@ 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;
                }
 
@@ -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);
                if (!entry) {
                        pr_err("pblk: could not scan entry on write failure\n");
+                       mempool_free(recovery, pblk->rec_pool);
                        goto out;
                }
 
@@ -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;
        }