Commit 507f7d68 authored by Javier González's avatar Javier González Committed by Jens Axboe

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: default avatarJavier González <javier@cnexlabs.com>
Reviewed-by: default avatarMatias Bjørling <matias@cnexlabs.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 2e13f33a
...@@ -74,7 +74,7 @@ static int nvm_reserve_luns(struct nvm_dev *dev, int lun_begin, int lun_end) ...@@ -74,7 +74,7 @@ static int nvm_reserve_luns(struct nvm_dev *dev, int lun_begin, int lun_end)
return 0; return 0;
err: err:
while (--i > lun_begin) while (--i >= lun_begin)
clear_bit(i, dev->lun_map); clear_bit(i, dev->lun_map);
return -EBUSY; return -EBUSY;
...@@ -211,7 +211,7 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev, ...@@ -211,7 +211,7 @@ static struct nvm_tgt_dev *nvm_create_tgt_dev(struct nvm_dev *dev,
return tgt_dev; return tgt_dev;
err_ch: err_ch:
while (--i > 0) while (--i >= 0)
kfree(dev_map->chnls[i].lun_offs); kfree(dev_map->chnls[i].lun_offs);
kfree(luns); kfree(luns);
err_luns: err_luns:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment