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>
This commit is contained in:
committed by
Martin K. Petersen
parent
61deab8a32
commit
867e4b1bae
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user