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.

scsi: core: Improve sdev_store_timeout()

Check whether or not the conversion of the argument to an integer
succeeded. Reject invalid timeout values.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251031221844.2921694-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
867e4b1b 61deab8a

+8 -4
+8 -4
drivers/scsi/scsi_sysfs.c
··· 648 648 sdev_store_timeout (struct device *dev, struct device_attribute *attr, 649 649 const char *buf, size_t count) 650 650 { 651 - struct scsi_device *sdev; 652 - int timeout; 653 - sdev = to_scsi_device(dev); 654 - sscanf (buf, "%d\n", &timeout); 651 + struct scsi_device *sdev = to_scsi_device(dev); 652 + int ret, timeout; 653 + 654 + ret = kstrtoint(buf, 0, &timeout); 655 + if (ret) 656 + return ret; 657 + if (timeout <= 0) 658 + return -EINVAL; 655 659 blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); 656 660 return count; 657 661 }