linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lightnvm: pblk: fix error path in pblk_lines_alloc_metadata
@ 2017-09-20 19:50 Rakesh Pandit
  2017-09-21  9:56 ` Javier González
  0 siblings, 1 reply; 4+ messages in thread
From: Rakesh Pandit @ 2017-09-20 19:50 UTC (permalink / raw)
  To: Matias Bjørling, linux-block, linux-kernel; +Cc: Javier González

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 <rakesh@tuxera.com>
---
 drivers/lightnvm/pblk-init.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 7cf4b53..470ef04 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -624,12 +624,16 @@ 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]);
 	}
 
+	i = PBLK_DATA_LINES;
 fail_free_smeta:
-	for (i = 0; i < PBLK_DATA_LINES; i++)
+	while (--i >= 0)
 		kfree(l_mg->sline_meta[i]);
 
 	return -ENOMEM;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-21 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-20 19:50 [PATCH] lightnvm: pblk: fix error path in pblk_lines_alloc_metadata Rakesh Pandit
2017-09-21  9:56 ` Javier González
2017-09-21 10:15   ` Rakesh Pandit
2017-09-21 11:14     ` Matias Bjørling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).