From: Wang Sheng-Hui <shhuiw@gmail.com>
To: chris.mason@fusionio.com, jbacik@fusionio.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Btrfs: check range early in map_private_extent_buffer
Date: Mon, 24 Sep 2012 12:38:07 +0800 [thread overview]
Message-ID: <505FE3AF.2090302@gmail.com> (raw)
Check range early to avoid further check/compute in case
of range error.
Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
---
fs/btrfs/extent_io.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 4c87847..9250cf5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4643,6 +4643,14 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
unsigned long end_i = (start_offset + start + min_len - 1) >>
PAGE_CACHE_SHIFT;
+ if (start + min_len > eb->len) {
+ printk(KERN_ERR "btrfs bad mapping eb start %llu len %lu, "
+ "wanted %lu %lu\n", (unsigned long long)eb->start,
+ eb->len, start, min_len);
+ WARN_ON(1);
+ return -EINVAL;
+ }
+
if (i != end_i)
return -EINVAL;
@@ -4654,14 +4662,6 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
*map_start = ((u64)i << PAGE_CACHE_SHIFT) - start_offset;
}
- if (start + min_len > eb->len) {
- printk(KERN_ERR "btrfs bad mapping eb start %llu len %lu, "
- "wanted %lu %lu\n", (unsigned long long)eb->start,
- eb->len, start, min_len);
- WARN_ON(1);
- return -EINVAL;
- }
-
p = extent_buffer_page(eb, i);
kaddr = page_address(p);
*map = kaddr + offset;
--
1.7.1
next reply other threads:[~2012-09-24 4:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 4:38 Wang Sheng-Hui [this message]
2012-09-24 16:17 ` Btrfs: check range early in map_private_extent_buffer David Sterba
2012-09-25 0:24 ` Wang Sheng-Hui
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=505FE3AF.2090302@gmail.com \
--to=shhuiw@gmail.com \
--cc=chris.mason@fusionio.com \
--cc=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.