From: Rakesh Pandit Date: Fri, 13 Oct 2017 12:45:54 +0000 (+0200) Subject: lightnvm: pblk: fix error path in pblk_lines_alloc_metadata X-Git-Tag: v5.15~10032^2~191 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9d84b350f9b253872fc24f4dcfea166c884ee15;p=platform%2Fkernel%2Flinux-starfive.git lightnvm: pblk: fix error path in pblk_lines_alloc_metadata Use appropriate memory free calls based on allocation type used and also fix number of times free is called if kmalloc fails. Signed-off-by: Rakesh Pandit Reviewed-by: Javier González Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe --- diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 6df65d1..05665a7 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -630,7 +630,10 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk) fail_free_emeta: while (--i >= 0) { - vfree(l_mg->eline_meta[i]->buf); + if (l_mg->emeta_alloc_type == PBLK_VMALLOC_META) + vfree(l_mg->eline_meta[i]->buf); + else + kfree(l_mg->eline_meta[i]->buf); kfree(l_mg->eline_meta[i]); }