aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/target/target_core_file.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 8f6dae074c2c..1fc5825b3912 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -236,7 +236,7 @@ static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl,
236 236
237 for_each_sg(sgl, sg, sgl_nents, i) { 237 for_each_sg(sgl, sg, sgl_nents, i) {
238 iov[i].iov_len = sg->length; 238 iov[i].iov_len = sg->length;
239 iov[i].iov_base = sg_virt(sg); 239 iov[i].iov_base = kmap(sg_page(sg)) + sg->offset;
240 } 240 }
241 241
242 old_fs = get_fs(); 242 old_fs = get_fs();
@@ -244,6 +244,8 @@ static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl,
244 ret = vfs_readv(fd, &iov[0], sgl_nents, &pos); 244 ret = vfs_readv(fd, &iov[0], sgl_nents, &pos);
245 set_fs(old_fs); 245 set_fs(old_fs);
246 246
247 for_each_sg(sgl, sg, sgl_nents, i)
248 kunmap(sg_page(sg));
247 kfree(iov); 249 kfree(iov);
248 /* 250 /*
249 * Return zeros and GOOD status even if the READ did not return 251 * Return zeros and GOOD status even if the READ did not return
@@ -288,7 +290,7 @@ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl,
288 290
289 for_each_sg(sgl, sg, sgl_nents, i) { 291 for_each_sg(sgl, sg, sgl_nents, i) {
290 iov[i].iov_len = sg->length; 292 iov[i].iov_len = sg->length;
291 iov[i].iov_base = sg_virt(sg); 293 iov[i].iov_base = kmap(sg_page(sg)) + sg->offset;
292 } 294 }
293 295
294 old_fs = get_fs(); 296 old_fs = get_fs();
@@ -296,6 +298,9 @@ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl,
296 ret = vfs_writev(fd, &iov[0], sgl_nents, &pos); 298 ret = vfs_writev(fd, &iov[0], sgl_nents, &pos);
297 set_fs(old_fs); 299 set_fs(old_fs);
298 300
301 for_each_sg(sgl, sg, sgl_nents, i)
302 kunmap(sg_page(sg));
303
299 kfree(iov); 304 kfree(iov);
300 305
301 if (ret < 0 || ret != cmd->data_length) { 306 if (ret < 0 || ret != cmd->data_length) {