Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vhost: vringh: Modify the return value check

The return value of copy_from_iter and copy_to_iter can't be negative,
check whether the copied lengths are equal.

Fixes: 309bba39c945 ("vringh: iterate on iotlb_translate to handle large translations")
Cc: "Stefano Garzarella" <sgarzare@redhat.com>
Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Message-Id: <20250910091739.2999-1-zhangjiao2@cmss.chinamobile.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

zhang jiao and committed by
Michael S. Tsirkin
82a8d0fd e5f0a698

+4 -3
+4 -3
drivers/vhost/vringh.c
··· 1115 1115 struct iov_iter iter; 1116 1116 u64 translated; 1117 1117 int ret; 1118 + size_t size; 1118 1119 1119 1120 ret = iotlb_translate(vrh, (u64)(uintptr_t)src, 1120 1121 len - total_translated, &translated, ··· 1133 1132 translated); 1134 1133 } 1135 1134 1136 - ret = copy_from_iter(dst, translated, &iter); 1137 - if (ret < 0) 1138 - return ret; 1135 + size = copy_from_iter(dst, translated, &iter); 1136 + if (size != translated) 1137 + return -EFAULT; 1139 1138 1140 1139 src += translated; 1141 1140 dst += translated;