Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1634821 > unrolled thread

[PATCH 2/2] lightnvm: fix bad back free on error path

Started by"Javier González" <jg@lightnvm.io>
First post2017-05-03 11:20 +0200
Last post2017-05-04 13:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] lightnvm: fix bad back free on error path "Javier González" <jg@lightnvm.io> - 2017-05-03 11:20 +0200
    Re: [PATCH 2/2] lightnvm: fix bad back free on error path Matias Bjørling <m@bjorling.me> - 2017-05-04 10:10 +0200
    Re: [PATCH 2/2] lightnvm: fix bad back free on error path Christoph Hellwig <hch@infradead.org> - 2017-05-04 13:30 +0200

#1634821 — [PATCH 2/2] lightnvm: fix bad back free on error path

From"Javier González" <jg@lightnvm.io>
Date2017-05-03 11:20 +0200
Subject[PATCH 2/2] lightnvm: fix bad back free on error path
Message-ID<tCYBX-3bN-7@gated-at.bofh.it>
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>
---
 drivers/lightnvm/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 54a06c3a2b8c..6a4aa608ad95 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:
-- 
2.7.4

[toc] | [next] | [standalone]


#1635466

FromMatias Bjørling <m@bjorling.me>
Date2017-05-04 10:10 +0200
Message-ID<tDjZM-MX-19@gated-at.bofh.it>
In reply to#1634821
On 05/03/2017 11:19 AM, Javier González wrote:
> 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>
> ---
>  drivers/lightnvm/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 54a06c3a2b8c..6a4aa608ad95 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:
>

Reviewed-by: Matias Bjørling <matias@cnexlabs.com>

Jens, and this baby as well? :)

[toc] | [prev] | [next] | [standalone]


#1635646

FromChristoph Hellwig <hch@infradead.org>
Date2017-05-04 13:30 +0200
Message-ID<tDn7j-2Ke-3@gated-at.bofh.it>
In reply to#1634821
Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web