diff options
| -rw-r--r-- | drivers/vhost/tcm_vhost.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c index defc28595656..62058d7a562f 100644 --- a/drivers/vhost/tcm_vhost.c +++ b/drivers/vhost/tcm_vhost.c | |||
| @@ -479,11 +479,9 @@ static int vhost_scsi_map_iov_to_sgl(struct tcm_vhost_cmd *tv_cmd, | |||
| 479 | * Find out how long sglist needs to be | 479 | * Find out how long sglist needs to be |
| 480 | */ | 480 | */ |
| 481 | sgl_count = 0; | 481 | sgl_count = 0; |
| 482 | for (i = 0; i < niov; i++) { | 482 | for (i = 0; i < niov; i++) |
| 483 | sgl_count += (((uintptr_t)iov[i].iov_base + iov[i].iov_len + | 483 | sgl_count += iov_num_pages(&iov[i]); |
| 484 | PAGE_SIZE - 1) >> PAGE_SHIFT) - | 484 | |
| 485 | ((uintptr_t)iov[i].iov_base >> PAGE_SHIFT); | ||
| 486 | } | ||
| 487 | /* TODO overflow checking */ | 485 | /* TODO overflow checking */ |
| 488 | 486 | ||
| 489 | sg = kmalloc(sizeof(tv_cmd->tvc_sgl[0]) * sgl_count, GFP_ATOMIC); | 487 | sg = kmalloc(sizeof(tv_cmd->tvc_sgl[0]) * sgl_count, GFP_ATOMIC); |
