Skip to content

Commit e3bf3df

Browse files
author
Al Viro
committed
[vhost] fix 'direction' argument of iov_iter_{init,bvec}()
READ means "data destination", WRITE - "data source". Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent b676668 commit e3bf3df

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/vhost/vhost.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static int vhost_copy_to_user(struct vhost_virtqueue *vq, void __user *to,
832832
VHOST_ACCESS_WO);
833833
if (ret < 0)
834834
goto out;
835-
iov_iter_init(&t, WRITE, vq->iotlb_iov, ret, size);
835+
iov_iter_init(&t, READ, vq->iotlb_iov, ret, size);
836836
ret = copy_to_iter(from, size, &t);
837837
if (ret == size)
838838
ret = 0;
@@ -871,7 +871,7 @@ static int vhost_copy_from_user(struct vhost_virtqueue *vq, void *to,
871871
(unsigned long long) size);
872872
goto out;
873873
}
874-
iov_iter_init(&f, READ, vq->iotlb_iov, ret, size);
874+
iov_iter_init(&f, WRITE, vq->iotlb_iov, ret, size);
875875
ret = copy_from_iter(to, size, &f);
876876
if (ret == size)
877877
ret = 0;
@@ -2135,7 +2135,7 @@ static int get_indirect(struct vhost_virtqueue *vq,
21352135
vq_err(vq, "Translation failure %d in indirect.\n", ret);
21362136
return ret;
21372137
}
2138-
iov_iter_init(&from, READ, vq->indirect, ret, len);
2138+
iov_iter_init(&from, WRITE, vq->indirect, ret, len);
21392139
count = len / sizeof desc;
21402140
/* Buffers are chained via a 16 bit next field, so
21412141
* we can have at most 2^16 of these. */

drivers/vhost/vringh.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ static inline int copy_from_iotlb(const struct vringh *vrh, void *dst,
11621162
else if (ret < 0)
11631163
return ret;
11641164

1165-
iov_iter_bvec(&iter, READ, iov, ret, translated);
1165+
iov_iter_bvec(&iter, WRITE, iov, ret, translated);
11661166

11671167
ret = copy_from_iter(dst, translated, &iter);
11681168
if (ret < 0)
@@ -1195,7 +1195,7 @@ static inline int copy_to_iotlb(const struct vringh *vrh, void *dst,
11951195
else if (ret < 0)
11961196
return ret;
11971197

1198-
iov_iter_bvec(&iter, WRITE, iov, ret, translated);
1198+
iov_iter_bvec(&iter, READ, iov, ret, translated);
11991199

12001200
ret = copy_to_iter(src, translated, &iter);
12011201
if (ret < 0)

0 commit comments

Comments
 (0)