aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pagemap.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r--include/linux/pagemap.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 862fc07dc6c0..8f1e390fd71b 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -219,6 +219,9 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size)
219{ 219{
220 int ret; 220 int ret;
221 221
222 if (unlikely(size == 0))
223 return 0;
224
222 /* 225 /*
223 * Writing zeroes into userspace here is OK, because we know that if 226 * Writing zeroes into userspace here is OK, because we know that if
224 * the zero gets there, we'll be overwriting it. 227 * the zero gets there, we'll be overwriting it.
@@ -238,19 +241,23 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size)
238 return ret; 241 return ret;
239} 242}
240 243
241static inline void fault_in_pages_readable(const char __user *uaddr, int size) 244static inline int fault_in_pages_readable(const char __user *uaddr, int size)
242{ 245{
243 volatile char c; 246 volatile char c;
244 int ret; 247 int ret;
245 248
249 if (unlikely(size == 0))
250 return 0;
251
246 ret = __get_user(c, uaddr); 252 ret = __get_user(c, uaddr);
247 if (ret == 0) { 253 if (ret == 0) {
248 const char __user *end = uaddr + size - 1; 254 const char __user *end = uaddr + size - 1;
249 255
250 if (((unsigned long)uaddr & PAGE_MASK) != 256 if (((unsigned long)uaddr & PAGE_MASK) !=
251 ((unsigned long)end & PAGE_MASK)) 257 ((unsigned long)end & PAGE_MASK))
252 __get_user(c, end); 258 ret = __get_user(c, end);
253 } 259 }
260 return ret;
254} 261}
255 262
256#endif /* _LINUX_PAGEMAP_H */ 263#endif /* _LINUX_PAGEMAP_H */