scsi: core: Improve sdev_store_timeout()
PATCH 1/1 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 <[email protected]>
--- drivers/scsi/scsi_sysfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/scsi/scsi_sysfs.c +8 -4
@@ -648,10 +648,14 @@ static ssize_t sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct scsi_device *sdev; -int timeout; - sdev =to_scsi_device (dev); -sscanf (buf,"%d\n" , &timeout); + struct scsi_device *sdev = to_scsi_device(dev); +int ret, timeout; + + ret =kstrtoint (buf,0 , &timeout); +if (ret) +return ret; +if (timeout <=0 ) +return -EINVAL ;blk_queue_rq_timeout (sdev->request_queue, timeout *HZ );return count; }
Bart,
Quoted 2 lines
Check whether or not the conversion of the argument to an integer succeeded. Reject invalid timeout values.
Reviewed-by Martin K. Petersen <[email protected]>
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 4 lines · Bart Van Assche
Check whether or not the conversion of the argument to an integer succeeded. Reject invalid timeout values.
Applied to 6.19/scsi-queue, thanks!
[1/1] scsi: core: Improve sdev_store_timeout()
https://git.kernel.org/mkp/scsi/c/867e4b1bae4b
Signature · 1 line
Martin K. Petersen