From: Zhao Hongjiang <zhaohongjiang@huawei.com>
To: <bharrosh@panasas.com>, <bhalevy@tonian.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, <osd-dev@open-osd.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] exofs: don't increase urilen if krealloc() fails
Date: Sun, 28 Apr 2013 19:46:38 +0800 [thread overview]
Message-ID: <517D0C1E.4090004@huawei.com> (raw)
Without the patch, edp->urilen is increased before krealloc(). If krealloc() fails,
edp->urilen is too high. Fix that by only updating edp->urilen if krealloc() is successful.
Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
---
fs/exofs/sys.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/exofs/sys.c b/fs/exofs/sys.c
index 1b4f2f9..79b0a85 100644
--- a/fs/exofs/sys.c
+++ b/fs/exofs/sys.c
@@ -82,11 +82,11 @@ static ssize_t uri_store(struct exofs_dev *edp, const char *buf, size_t len)
{
uint8_t *new_uri;
- edp->urilen = strlen(buf) + 1;
- new_uri = krealloc(edp->uri, edp->urilen, GFP_KERNEL);
+ new_uri = krealloc(edp->uri, strlen(buf) + 1, GFP_KERNEL);
if (new_uri == NULL)
return -ENOMEM;
edp->uri = new_uri;
+ edp->urilen = strlen(buf) + 1;
strncpy(edp->uri, buf, edp->urilen);
return edp->urilen;
}
-- 1.7.1
next reply other threads:[~2013-04-28 11:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-28 11:46 Zhao Hongjiang [this message]
2013-04-29 16:40 ` [PATCH] exofs: don't increase urilen if krealloc() fails Boaz Harrosh
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=517D0C1E.4090004@huawei.com \
--to=zhaohongjiang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=bhalevy@tonian.com \
--cc=bharrosh@panasas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=osd-dev@open-osd.org \
/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