From: "Javier González" <jg@lightnvm.io>
To: mb@lightnvm.io
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Javier González" <javier@cnexlabs.com>
Subject: [PATCH 2/2] lightnvm: fix bad back free on error path
Date: Wed, 3 May 2017 11:19:05 +0200 [thread overview]
Message-ID: <1493803145-18082-2-git-send-email-javier@cnexlabs.com> (raw)
In-Reply-To: <1493803145-18082-1-git-send-email-javier@cnexlabs.com>
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
next prev parent reply other threads:[~2017-05-03 9:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 9:19 [PATCH 1/2] lightnvm: create cmd before allocating request Javier González
2017-05-03 9:19 ` Javier González [this message]
2017-05-04 8:04 ` [PATCH 2/2] lightnvm: fix bad back free on error path Matias Bjørling
2017-05-04 11:27 ` Christoph Hellwig
2017-05-04 8:04 ` [PATCH 1/2] lightnvm: create cmd before allocating request Matias Bjørling
2017-05-04 11:27 ` Christoph Hellwig
2017-05-04 13:53 ` Jens Axboe
2017-05-04 13:55 ` Javier González
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493803145-18082-2-git-send-email-javier@cnexlabs.com \
--to=jg@lightnvm.io \
--cc=javier@cnexlabs.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®