Skip to content

Commit bd46fc4

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: sg: off by one in sg_ioctl()
If "val" is SG_MAX_QUEUE then we are one element beyond the end of the "rinfo" array so the > should be >=. Fixes: 109bade ("scsi: sg: use standard lists for sg_requests") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 723cd77 commit bd46fc4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/sg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
10211021
read_lock_irqsave(&sfp->rq_list_lock, iflags);
10221022
val = 0;
10231023
list_for_each_entry(srp, &sfp->rq_list, entry) {
1024-
if (val > SG_MAX_QUEUE)
1024+
if (val >= SG_MAX_QUEUE)
10251025
break;
10261026
memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
10271027
rinfo[val].req_state = srp->done + 1;

0 commit comments

Comments
 (0)