Skip to content

Commit 400cad5

Browse files
aloktiwamstsirkin
authored andcommitted
vhost-scsi: Fix check for inline_sg_cnt exceeding preallocated limit
The condition comparing ret to VHOST_SCSI_PREALLOC_SGLS was incorrect, as ret holds the result of kstrtouint() (typically 0 on success), not the parsed value. Update the check to use cnt, which contains the actual user-provided value. prevents silently accepting values exceeding the maximum inline_sg_cnt. Fixes: bca939d ("vhost-scsi: Dynamically allocate scatterlists") Signed-off-by: Alok Tiwari <[email protected]> Reviewed-by: Mike Christie <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 95109b4 commit 400cad5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/vhost/scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int vhost_scsi_set_inline_sg_cnt(const char *buf,
7171
if (ret)
7272
return ret;
7373

74-
if (ret > VHOST_SCSI_PREALLOC_SGLS) {
74+
if (cnt > VHOST_SCSI_PREALLOC_SGLS) {
7575
pr_err("Max inline_sg_cnt is %u\n", VHOST_SCSI_PREALLOC_SGLS);
7676
return -EINVAL;
7777
}

0 commit comments

Comments
 (0)