diff options
Diffstat (limited to 'net/rds/page.c')
-rw-r--r-- | net/rds/page.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/net/rds/page.c b/net/rds/page.c index a3e2e0ac8a60..d8acdebe3c7c 100644 --- a/net/rds/page.c +++ b/net/rds/page.c | |||
@@ -58,30 +58,17 @@ int rds_page_copy_user(struct page *page, unsigned long offset, | |||
58 | unsigned long ret; | 58 | unsigned long ret; |
59 | void *addr; | 59 | void *addr; |
60 | 60 | ||
61 | if (to_user) | 61 | addr = kmap(page); |
62 | if (to_user) { | ||
62 | rds_stats_add(s_copy_to_user, bytes); | 63 | rds_stats_add(s_copy_to_user, bytes); |
63 | else | 64 | ret = copy_to_user(ptr, addr + offset, bytes); |
65 | } else { | ||
64 | rds_stats_add(s_copy_from_user, bytes); | 66 | rds_stats_add(s_copy_from_user, bytes); |
65 | 67 | ret = copy_from_user(addr + offset, ptr, bytes); | |
66 | addr = kmap_atomic(page, KM_USER0); | ||
67 | if (to_user) | ||
68 | ret = __copy_to_user_inatomic(ptr, addr + offset, bytes); | ||
69 | else | ||
70 | ret = __copy_from_user_inatomic(addr + offset, ptr, bytes); | ||
71 | kunmap_atomic(addr, KM_USER0); | ||
72 | |||
73 | if (ret) { | ||
74 | addr = kmap(page); | ||
75 | if (to_user) | ||
76 | ret = copy_to_user(ptr, addr + offset, bytes); | ||
77 | else | ||
78 | ret = copy_from_user(addr + offset, ptr, bytes); | ||
79 | kunmap(page); | ||
80 | if (ret) | ||
81 | return -EFAULT; | ||
82 | } | 68 | } |
69 | kunmap(page); | ||
83 | 70 | ||
84 | return 0; | 71 | return ret ? -EFAULT : 0; |
85 | } | 72 | } |
86 | EXPORT_SYMBOL_GPL(rds_page_copy_user); | 73 | EXPORT_SYMBOL_GPL(rds_page_copy_user); |
87 | 74 | ||