summaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-05-03 11:19:05 +0200
committerJens Axboe <axboe@fb.com>2017-05-04 07:53:04 -0600
commit507f7d68fe5c24973dcd6e48f011bdfbd2197f01 (patch)
treee16f1c40edecd3d0cfc5a358cfafe58eba604708 /drivers/lightnvm
parent2e13f33a2464fc3aa7783022a90309cabeca8935 (diff)
downloadop-kernel-dev-507f7d68fe5c24973dcd6e48f011bdfbd2197f01.zip
op-kernel-dev-507f7d68fe5c24973dcd6e48f011bdfbd2197f01.tar.gz
lightnvm: fix bad back free on error path
Free memory correctly when an allocation fails on a loop and we free backwards previously successful allocations. Signed-off-by: Javier González <javier@cnexlabs.com> Reviewed-by: Matias Bjørling <matias@cnexlabs.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r--drivers/lightnvm/core.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 54a06c3..6a4aa60 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -74,7 +74,7 @@ static int nvm_reserve_luns(struct nvm_dev *dev, int lun_begin, int lun_end)
return 0;
err:
- while (--i > lun_begin)
+ while (--i >= lun_begin)
clear_bit(i, dev->lun_map);
return -EBUSY;
@@ -211,7 +211,7 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev,
return tgt_dev;
err_ch:
- while (--i > 0)
+ while (--i >= 0)
kfree(dev_map->chnls[i].lun_offs);
kfree(luns);
err_luns:
OpenPOWER on IntegriCloud