Skip to content

Commit

Permalink
lightnvm: fix bad back free on error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Javier González authored and axboe committed May 4, 2017
1 parent 2e13f33 commit 507f7d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 507f7d6

Please sign in to comment.