summaryrefslogtreecommitdiffstats
path: root/lib/iov_iter.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2023-07-16 05:03:52 +0200
committerMatthew Wilcox (Oracle) <willy@infradead.org>2023-07-25 00:03:43 +0200
commitf7f9a0c8736d418af8d981000ea68ea43b395da4 (patch)
treead45846d2b69133e11fa8537ca8f649ae232f493 /lib/iov_iter.c
parentLinux 6.5-rc3 (diff)
downloadlinux-f7f9a0c8736d418af8d981000ea68ea43b395da4.tar.xz
linux-f7f9a0c8736d418af8d981000ea68ea43b395da4.zip
iov_iter: Map the page later in copy_page_from_iter_atomic()
Remove a couple of calls to kunmap_atomic() in the rare error cases. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kent Overstreet <kent.overstreet@linux.dev> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'lib/iov_iter.c')
-rw-r--r--lib/iov_iter.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index e4dc809d1075..db58af778291 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -569,20 +569,20 @@ EXPORT_SYMBOL(iov_iter_zero);
size_t copy_page_from_iter_atomic(struct page *page, unsigned offset, size_t bytes,
struct iov_iter *i)
{
- char *kaddr = kmap_atomic(page), *p = kaddr + offset;
- if (!page_copy_sane(page, offset, bytes)) {
- kunmap_atomic(kaddr);
+ char *p;
+
+ if (!page_copy_sane(page, offset, bytes))
return 0;
- }
- if (WARN_ON_ONCE(!i->data_source)) {
- kunmap_atomic(kaddr);
+ if (WARN_ON_ONCE(!i->data_source))
return 0;
- }
+
+ p = kmap_atomic(page) + offset;
iterate_and_advance(i, bytes, base, len, off,
copyin(p + off, base, len),
memcpy_from_iter(i, p + off, base, len)
)
- kunmap_atomic(kaddr);
+ kunmap_atomic(p);
+
return bytes;
}
EXPORT_SYMBOL(copy_page_from_iter_atomic);