diff options
author | Matias Bjørling <m@bjorling.me> | 2015-11-16 15:34:43 +0100 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-11-16 23:20:33 +0100 |
commit | c1480ad5943261e01a62eaa7132eab76f9c490e0 (patch) | |
tree | ad2c41ab89caa8ae004636b26d495be3f9bbef9b /drivers/lightnvm/core.c | |
parent | lightnvm: prematurely activate nvm_dev (diff) | |
download | linux-c1480ad5943261e01a62eaa7132eab76f9c490e0.tar.xz linux-c1480ad5943261e01a62eaa7132eab76f9c490e0.zip |
lightnvm: prevent double free on init error
Both the nvm_register and nvm_init does a kfree(dev) on error. Make sure
to only free it once.
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r-- | drivers/lightnvm/core.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 40e6cfae4585..899f6b9a9f68 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -160,11 +160,6 @@ int nvm_erase_blk(struct nvm_dev *dev, struct nvm_block *blk) } EXPORT_SYMBOL(nvm_erase_blk); -static void nvm_core_free(struct nvm_dev *dev) -{ - kfree(dev); -} - static int nvm_core_init(struct nvm_dev *dev) { struct nvm_id *id = &dev->identity; @@ -223,8 +218,6 @@ static void nvm_free(struct nvm_dev *dev) if (dev->mt) dev->mt->unregister_mgr(dev); - - nvm_core_free(dev); } static int nvm_init(struct nvm_dev *dev) @@ -351,11 +344,12 @@ void nvm_unregister(char *disk_name) return; } - nvm_exit(dev); - down_write(&nvm_lock); list_del(&dev->devices); up_write(&nvm_lock); + + nvm_exit(dev); + kfree(dev); } EXPORT_SYMBOL(nvm_unregister); |