Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1276448
| From | Matias Bjørling <m@bjorling.me> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/5] lightnvm: free memory when gennvm register fails |
| Date | 2015-11-24 14:30 +0100 |
| Message-ID | <qylPt-cQ-39@gated-at.bofh.it> (permalink) |
| References | <qylPs-cQ-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Wenwei Tao <ww.tao0320@gmail.com>
free allocated nvm block and gennvm lun structures when
gennvm register fails, otherwise it will cause memory leak.
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
drivers/lightnvm/gennvm.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index e20e74e..3969a98 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -207,6 +207,14 @@ static int gennvm_blocks_init(struct nvm_dev *dev, struct gen_nvm *gn)
return 0;
}
+static void gennvm_free(struct nvm_dev *dev)
+{
+ gennvm_blocks_free(dev);
+ gennvm_luns_free(dev);
+ kfree(dev->mp);
+ dev->mp = NULL;
+}
+
static int gennvm_register(struct nvm_dev *dev)
{
struct gen_nvm *gn;
@@ -234,16 +242,13 @@ static int gennvm_register(struct nvm_dev *dev)
return 1;
err:
- kfree(gn);
+ gennvm_free(dev);
return ret;
}
static void gennvm_unregister(struct nvm_dev *dev)
{
- gennvm_blocks_free(dev);
- gennvm_luns_free(dev);
- kfree(dev->mp);
- dev->mp = NULL;
+ gennvm_free(dev);
}
static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 0/5] LightNVM fixes Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
[PATCH 1/5] lightnvm: change vendor and dev id for qemu Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
RE: [PATCH 1/5] lightnvm: change vendor and dev id for qemu "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2015-11-24 17:00 +0100
Re: [PATCH 1/5] lightnvm: change vendor and dev id for qemu Matias Bjørling <m@bjorling.me> - 2015-11-24 19:30 +0100
Re: [PATCH 1/5] lightnvm: change vendor and dev id for qemu Jens Axboe <axboe@fb.com> - 2015-11-24 23:30 +0100
[PATCH 2/5] lightnvm: Simplify config when disabled Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
[PATCH 5/5] lightnvm: do device max sectors boundary check first Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
[PATCH 4/5] lightnvm: fix ioctl memory leaks Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
[PATCH 3/5] lightnvm: free memory when gennvm register fails Matias Bjørling <m@bjorling.me> - 2015-11-24 14:30 +0100
csiph-web