aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2010-10-26 17:21:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:08 -0400
commit61ecdb801ef2cd28e32442383106d7837d76deac (patch)
tree3ec4f04e09cc4a9b76dafaaa0c4dfd07e825e632
parent2e30244a7cc1ff09013a1238d415b4076406388e (diff)
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>
-rw-r--r--crypto/async_tx/async_memcpy.c2
-rw-r--r--crypto/blkcipher.c2
-rw-r--r--drivers/block/loop.c4
-rw-r--r--include/linux/highmem.h4
-rw-r--r--kernel/power/snapshot.c4
5 files changed, 8 insertions, 8 deletions
diff --git a/crypto/async_tx/async_memcpy.c b/crypto/async_tx/async_memcpy.c
index 0ec1fb69d4ea..518c22bd9562 100644
--- a/crypto/async_tx/async_memcpy.c
+++ b/crypto/async_tx/async_memcpy.c
@@ -83,8 +83,8 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset,
83 83
84 memcpy(dest_buf, src_buf, len); 84 memcpy(dest_buf, src_buf, len);
85 85
86 kunmap_atomic(dest_buf, KM_USER0);
87 kunmap_atomic(src_buf, KM_USER1); 86 kunmap_atomic(src_buf, KM_USER1);
87 kunmap_atomic(dest_buf, KM_USER0);
88 88
89 async_tx_sync_epilog(submit); 89 async_tx_sync_epilog(submit);
90 } 90 }
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index 90d26c91f4e9..7a7219266e3c 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -89,9 +89,9 @@ static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
89 memcpy(walk->dst.virt.addr, walk->page, n); 89 memcpy(walk->dst.virt.addr, walk->page, n);
90 blkcipher_unmap_dst(walk); 90 blkcipher_unmap_dst(walk);
91 } else if (!(walk->flags & BLKCIPHER_WALK_PHYS)) { 91 } else if (!(walk->flags & BLKCIPHER_WALK_PHYS)) {
92 blkcipher_unmap_src(walk);
93 if (walk->flags & BLKCIPHER_WALK_DIFF) 92 if (walk->flags & BLKCIPHER_WALK_DIFF)
94 blkcipher_unmap_dst(walk); 93 blkcipher_unmap_dst(walk);
94 blkcipher_unmap_src(walk);
95 } 95 }
96 96
97 scatterwalk_advance(&walk->in, n); 97 scatterwalk_advance(&walk->in, n);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6c48b3545f84..450c958b514f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -101,8 +101,8 @@ static int transfer_none(struct loop_device *lo, int cmd,
101 else 101 else
102 memcpy(raw_buf, loop_buf, size); 102 memcpy(raw_buf, loop_buf, size);
103 103
104 kunmap_atomic(raw_buf, KM_USER0);
105 kunmap_atomic(loop_buf, KM_USER1); 104 kunmap_atomic(loop_buf, KM_USER1);
105 kunmap_atomic(raw_buf, KM_USER0);
106 cond_resched(); 106 cond_resched();
107 return 0; 107 return 0;
108} 108}
@@ -130,8 +130,8 @@ static int transfer_xor(struct loop_device *lo, int cmd,
130 for (i = 0; i < size; i++) 130 for (i = 0; i < size; i++)
131 *out++ = *in++ ^ key[(i & 511) % keysize]; 131 *out++ = *in++ ^ key[(i & 511) % keysize];
132 132
133 kunmap_atomic(raw_buf, KM_USER0);
134 kunmap_atomic(loop_buf, KM_USER1); 133 kunmap_atomic(loop_buf, KM_USER1);
134 kunmap_atomic(raw_buf, KM_USER0);
135 cond_resched(); 135 cond_resched();
136 return 0; 136 return 0;
137} 137}
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index e3060ef85b6d..283cd47bb34c 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -201,8 +201,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from,
201 vfrom = kmap_atomic(from, KM_USER0); 201 vfrom = kmap_atomic(from, KM_USER0);
202 vto = kmap_atomic(to, KM_USER1); 202 vto = kmap_atomic(to, KM_USER1);
203 copy_user_page(vto, vfrom, vaddr, to); 203 copy_user_page(vto, vfrom, vaddr, to);
204 kunmap_atomic(vfrom, KM_USER0);
205 kunmap_atomic(vto, KM_USER1); 204 kunmap_atomic(vto, KM_USER1);
205 kunmap_atomic(vfrom, KM_USER0);
206} 206}
207 207
208#endif 208#endif
@@ -214,8 +214,8 @@ static inline void copy_highpage(struct page *to, struct page *from)
214 vfrom = kmap_atomic(from, KM_USER0); 214 vfrom = kmap_atomic(from, KM_USER0);
215 vto = kmap_atomic(to, KM_USER1); 215 vto = kmap_atomic(to, KM_USER1);
216 copy_page(vto, vfrom); 216 copy_page(vto, vfrom);
217 kunmap_atomic(vfrom, KM_USER0);
218 kunmap_atomic(vto, KM_USER1); 217 kunmap_atomic(vto, KM_USER1);
218 kunmap_atomic(vfrom, KM_USER0);
219} 219}
220 220
221#endif /* _LINUX_HIGHMEM_H */ 221#endif /* _LINUX_HIGHMEM_H */
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index ac7eb109f196..9e3581f4619a 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -984,8 +984,8 @@ static void copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
984 src = kmap_atomic(s_page, KM_USER0); 984 src = kmap_atomic(s_page, KM_USER0);
985 dst = kmap_atomic(d_page, KM_USER1); 985 dst = kmap_atomic(d_page, KM_USER1);
986 do_copy_page(dst, src); 986 do_copy_page(dst, src);
987 kunmap_atomic(src, KM_USER0);
988 kunmap_atomic(dst, KM_USER1); 987 kunmap_atomic(dst, KM_USER1);
988 kunmap_atomic(src, KM_USER0);
989 } else { 989 } else {
990 if (PageHighMem(d_page)) { 990 if (PageHighMem(d_page)) {
991 /* Page pointed to by src may contain some kernel 991 /* 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)
2273 memcpy(buf, kaddr1, PAGE_SIZE); 2273 memcpy(buf, kaddr1, PAGE_SIZE);
2274 memcpy(kaddr1, kaddr2, PAGE_SIZE); 2274 memcpy(kaddr1, kaddr2, PAGE_SIZE);
2275 memcpy(kaddr2, buf, PAGE_SIZE); 2275 memcpy(kaddr2, buf, PAGE_SIZE);
2276 kunmap_atomic(kaddr1, KM_USER0);
2277 kunmap_atomic(kaddr2, KM_USER1); 2276 kunmap_atomic(kaddr2, KM_USER1);
2277 kunmap_atomic(kaddr1, KM_USER0);
2278} 2278}
2279 2279
2280/** 2280/**