Skip to content

Commit 61ecdb8

Browse files
Peter Zijlstratorvalds
authored andcommitted
mm: strictly nested kmap_atomic()
Ensure kmap_atomic() usage is strictly nested Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Reviewed-by: Rik van Riel <riel@redhat.com> Acked-by: Chris Metcalf <cmetcalf@tilera.com> Cc: David Howells <dhowells@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: David Miller <davem@davemloft.net> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2e30244 commit 61ecdb8

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎crypto/async_tx/async_memcpy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
8383

8484
memcpy(dest_buf, src_buf, len);
8585

86-
kunmap_atomic(dest_buf, KM_USER0);
8786
kunmap_atomic(src_buf, KM_USER1);
87+
kunmap_atomic(dest_buf, KM_USER0);
8888

8989
async_tx_sync_epilog(submit);
9090
}

‎crypto/blkcipher.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
8989
memcpy(walk->dst.virt.addr, walk->page, n);
9090
blkcipher_unmap_dst(walk);
9191
} else if (!(walk->flags & BLKCIPHER_WALK_PHYS)) {
92-
blkcipher_unmap_src(walk);
9392
if (walk->flags & BLKCIPHER_WALK_DIFF)
9493
blkcipher_unmap_dst(walk);
94+
blkcipher_unmap_src(walk);
9595
}
9696

9797
scatterwalk_advance(&walk->in, n);

‎drivers/block/loop.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ static int transfer_none(struct loop_device *lo, int cmd,
101101
else
102102
memcpy(raw_buf, loop_buf, size);
103103

104-
kunmap_atomic(raw_buf, KM_USER0);
105104
kunmap_atomic(loop_buf, KM_USER1);
105+
kunmap_atomic(raw_buf, KM_USER0);
106106
cond_resched();
107107
return 0;
108108
}
@@ -130,8 +130,8 @@ static int transfer_xor(struct loop_device *lo, int cmd,
130130
for (i = 0; i < size; i++)
131131
*out++ = *in++ ^ key[(i & 511) % keysize];
132132

133-
kunmap_atomic(raw_buf, KM_USER0);
134133
kunmap_atomic(loop_buf, KM_USER1);
134+
kunmap_atomic(raw_buf, KM_USER0);
135135
cond_resched();
136136
return 0;
137137
}

‎include/linux/highmem.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
201201
vfrom = kmap_atomic(from, KM_USER0);
202202
vto = kmap_atomic(to, KM_USER1);
203203
copy_user_page(vto, vfrom, vaddr, to);
204-
kunmap_atomic(vfrom, KM_USER0);
205204
kunmap_atomic(vto, KM_USER1);
205+
kunmap_atomic(vfrom, KM_USER0);
206206
}
207207

208208
#endif
@@ -214,8 +214,8 @@ static inline void copy_highpage(struct page *to, struct page *from)
214214
vfrom = kmap_atomic(from, KM_USER0);
215215
vto = kmap_atomic(to, KM_USER1);
216216
copy_page(vto, vfrom);
217-
kunmap_atomic(vfrom, KM_USER0);
218217
kunmap_atomic(vto, KM_USER1);
218+
kunmap_atomic(vfrom, KM_USER0);
219219
}
220220

221221
#endif /* _LINUX_HIGHMEM_H */

‎kernel/power/snapshot.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
984984
src = kmap_atomic(s_page, KM_USER0);
985985
dst = kmap_atomic(d_page, KM_USER1);
986986
do_copy_page(dst, src);
987-
kunmap_atomic(src, KM_USER0);
988987
kunmap_atomic(dst, KM_USER1);
988+
kunmap_atomic(src, KM_USER0);
989989
} else {
990990
if (PageHighMem(d_page)) {
991991
/* Page pointed to by src may contain some kernel
@@ -2273,8 +2273,8 @@ swap_two_pages_data(struct page *p1, struct page *p2, void *buf)
22732273
memcpy(buf, kaddr1, PAGE_SIZE);
22742274
memcpy(kaddr1, kaddr2, PAGE_SIZE);
22752275
memcpy(kaddr2, buf, PAGE_SIZE);
2276-
kunmap_atomic(kaddr1, KM_USER0);
22772276
kunmap_atomic(kaddr2, KM_USER1);
2277+
kunmap_atomic(kaddr1, KM_USER0);
22782278
}
22792279

22802280
/**

0 commit comments

Comments
 (0)