diff mbox series

scsi: sr: fix signed integer overflow

Message ID 20231218095054.12228-1-jiangjianjun3@huawei.com (mailing list archive)
State New, archived
Headers show
Series scsi: sr: fix signed integer overflow | expand

Commit Message

JiangJianJun Dec. 18, 2023, 9:50 a.m. UTC
Checking the range of the parameter speed, avoid integer overflow.

Signed-off-by: JiangJianJun <jiangjianjun3@huawei.com>
---
 drivers/scsi/sr_ioctl.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 5b0b35e60e61..d5b2cd80d171 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -430,6 +430,8 @@  int sr_select_speed(struct cdrom_device_info *cdi, int speed)
 	Scsi_CD *cd = cdi->handle;
 	struct packet_command cgc;
 
+	if (speed < 0 || speed > (INT_MAX / 177))
+		return -EINVAL;
 	if (speed == 0)
 		speed = 0xffff;	/* set to max */
 	else