diff mbox

[3/5] lightnvm: pblk: fix memory leak on error path

Message ID 1492817569-13532-4-git-send-email-javier@cnexlabs.com (mailing list archive)
State New, archived
Headers show

Commit Message

=?UTF-8?q?Javier=20Gonz=C3=A1lez?= April 21, 2017, 11:32 p.m. UTC
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>
---
 drivers/lightnvm/pblk-write.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Matias Bjorling April 22, 2017, 8:57 a.m. UTC | #1
On 04/22/2017 01:32 AM, Javier González wrote:
> 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>
> ---
>  drivers/lightnvm/pblk-write.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
> index 74f7413..a896190 100644
> --- a/drivers/lightnvm/pblk-write.c
> +++ b/drivers/lightnvm/pblk-write.c
> @@ -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;
>  	}
>
>
Reviewed-by: Matias Bjørling <matias@cnexlabs.com>
diff mbox

Patch

diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c
index 74f7413..a896190 100644
--- a/drivers/lightnvm/pblk-write.c
+++ b/drivers/lightnvm/pblk-write.c
@@ -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;
 	}