Skip to content

Commit 9642c8c

Browse files
author
Andreas Gruenbacher
committed
gfs2: Only dereference i->iov when iter_is_iovec(i)
Only dereference i->iov after establishing that i is of type ITER_IOVEC. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 78805cb commit 9642c8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/gfs2/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,8 @@ static inline bool should_fault_in_pages(ssize_t ret, struct iov_iter *i,
773773
size_t *prev_count,
774774
size_t *window_size)
775775
{
776-
char __user *p = i->iov[0].iov_base + i->iov_offset;
777776
size_t count = iov_iter_count(i);
777+
char __user *p;
778778
int pages = 1;
779779

780780
if (likely(!count))
@@ -787,14 +787,14 @@ static inline bool should_fault_in_pages(ssize_t ret, struct iov_iter *i,
787787
if (*prev_count != count || !*window_size) {
788788
int pages, nr_dirtied;
789789

790-
pages = min_t(int, BIO_MAX_VECS,
791-
DIV_ROUND_UP(iov_iter_count(i), PAGE_SIZE));
790+
pages = min_t(int, BIO_MAX_VECS, DIV_ROUND_UP(count, PAGE_SIZE));
792791
nr_dirtied = max(current->nr_dirtied_pause -
793792
current->nr_dirtied, 1);
794793
pages = min(pages, nr_dirtied);
795794
}
796795

797796
*prev_count = count;
797+
p = i->iov[0].iov_base + i->iov_offset;
798798
*window_size = (size_t)PAGE_SIZE * pages - offset_in_page(p);
799799
return true;
800800
}

0 commit comments

Comments
 (0)