lightnvm: avoid memory leak when lun_map kcalloc fails
authorMatias Bjørling <m@bjorling.me>
Fri, 6 May 2016 18:02:59 +0000 (20:02 +0200)
committerJens Axboe <axboe@fb.com>
Fri, 6 May 2016 18:51:10 +0000 (12:51 -0600)
commit7f7c5d03c0e8e177d1ed1c6412ae035e8eff35de
tree1a354500001df077c63e14ba63c29fc43d375fcf
parent22e8c9766a669d49cf3749d397082a5cd93374a9
lightnvm: avoid memory leak when lun_map kcalloc fails

A memory leak occurs if the lower page table is initialized and the
following dev->lun_map fails on allocation.

Rearrange the initialization of lower page table to allow dev->lun_map
to fail gracefully without memory leak.

Reviewed by: Johannes Thumshirn <jthumshirn@suse.de>
Move kfree of dev->lun_map to nvm_free()
Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/lightnvm/core.c