lkml.org 
[lkml]   [2019]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lightnvm: prevent memory leak in nvm_bb_chunk_sense
Date
In nvm_bb_chunk_sense alloc_page allocates memory which is released at
the end of the function. But if nvm_submit_io_sync_raw fails the error
check skips the release and leaks the allocated page. To fix this issue
I moved the __free_page call before error check.

Fixes: aff3fb18f957 ("lightnvm: move bad block and chunk state logic to core")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/lightnvm/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 7543e395a2c6..5fdae518f6c9 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -849,11 +849,12 @@ 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);
- if (ret)
- return ret;

__free_page(page);

+ if (ret)
+ return ret;
+
return rqd.error;
}

--
2.17.1
\
 
 \ /
  Last update: 2019-09-30 04:35    [W:0.039 / U:0.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site