[PATCH] sg: fix integer overflow

Mikulas Patocka
2014-01-24T16:34:48Z

On alpha, USER_HZ may be higher than HZ. This results in integer overflow
in MULDIV.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
drivers/scsi/sg.c | 2 ++
1 file changed, 2 insertions(+)

Index: linux-3.13/drivers/scsi/sg.c
===================================================================
--- linux-3.13.orig/drivers/scsi/sg.c 2014-01-20 21:44:02.000000000 +0100
+++ linux-3.13/drivers/scsi/sg.c 2014-01-24 17:28:02.000000000 +0100
@@ -856,8 +856,10 @@ sg_ioctl(struct file *filp, unsigned int
return result;
if (val < 0)
return -EIO;
+#if USER_HZ < HZ
if (val >= MULDIV (INT_MAX, USER_HZ, HZ))
val = MULDIV (INT_MAX, USER_HZ, HZ);
+#endif
sfp->timeout_user = val;
sfp->timeout = MULDIV (val, HZ, USER_HZ);