From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu,
Navid Emamdoost <navid.emamdoost@gmail.com>,
Matias Bjorling <mb@lightnvm.io>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] lightnvm: prevent memory leak in nvm_bb_chunk_sense
Date: Sun, 29 Sep 2019 21:34:14 -0500 [thread overview]
Message-ID: <20190930023415.24171-1-navid.emamdoost@gmail.com> (raw)
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
next reply other threads:[~2019-09-30 2:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 2:34 Navid Emamdoost [this message]
2019-09-30 7:16 ` Markus Elfring
2019-09-30 8:06 ` Javier González
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190930023415.24171-1-navid.emamdoost@gmail.com \
--to=navid.emamdoost@gmail.com \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
--cc=smccaman@umn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®