linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lightnvm: fix memory leak when submit fails
@ 2021-01-21  7:22 Pan Bian
  2021-01-21 12:47 ` Jens Axboe
  0 siblings, 1 reply; 9+ messages in thread
From: Pan Bian @ 2021-01-21  7:22 UTC (permalink / raw)
  To: Matias Bjorling, Jens Axboe; +Cc: linux-block, linux-kernel, Pan Bian

The allocated page is not released if error occurs in
nvm_submit_io_sync_raw(). __free_page() is moved ealier to avoid
possible memory leak issue.

Fixes: aff3fb18f957 ("lightnvm: move bad block and chunk state logic to core")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/lightnvm/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index c1bcac71008c..28ddcaa5358b 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -844,11 +844,10 @@ static int nvm_bb_chunk_sense(struct nvm_dev *dev, struct ppa_addr ppa)
 	rqd.ppa_addr = generic_to_dev_addr(dev, ppa);
 
 	ret = nvm_submit_io_sync_raw(dev, &rqd);
+	__free_page(page);
 	if (ret)
 		return ret;
 
-	__free_page(page);
-
 	return rqd.error;
 }
 
-- 
2.17.1



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

end of thread, other threads:[~2021-01-21 23:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  7:22 [PATCH] lightnvm: fix memory leak when submit fails Pan Bian
2021-01-21 12:47 ` Jens Axboe
2021-01-21 13:28   ` Javier González
2021-01-21 13:55   ` Matias Bjørling
2021-01-21 16:58     ` Heiner Litz
2021-01-21 18:25       ` Matias Bjørling
2021-01-21 19:49         ` Heiner Litz
2021-01-21 20:14           ` Matias Bjørling
2021-01-21 23:20             ` Heiner Litz

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).