tipar char driver (divide by zero)
PATCH 1/1 tipar char driver (divide by zero)
Hi,
a set of 2 patches (2.4 & 2.6) about the tipar.c char driver. It fixes a divide-by-zero error when we try to read/write data after setting timeout to 0.
Please apply...
Romain.
============================[cut here]==========================
drivers/char/tipar.c +12 -6
@@ -66,7 +66,7 @@/* * Version Information */ -#define DRIVER_VERSION "1.18" +#define DRIVER_VERSION "1.19"#define DRIVER_AUTHOR "Romain Lievin <[email protected]>"#define DRIVER_DESC "Device driver for TI/PC parallel link cables"#define DRIVER_LICENSE "GPL"
@@ -364,11 +364,14 @@switch (cmd) {case IOCTL_TIPAR_DELAY : - delay = (int )arg;//get_user(delay, &arg); -break ; + delay = (int )arg;//get_user(delay, &arg); +break ;case IOCTL_TIPAR_TIMEOUT : - timeout = (int )arg;//get_user(timeout, &arg); -break ; +if (arg !=0 ) + timeout = (int )arg; +else + retval = -EINVAL ; +break ;default : retval = -ENOTTY ;break ;
@@ -402,7 +405,10 @@ str =get_options (str,ARRAY_SIZE (ints), ints);if (ints[0 ] >0 ) { - timeout = ints[1 ]; +if (ints[1 ] !=0 ) + timeout = ints[1 ]; +else +printk ("tipar: wrong timeout value (0), using default value instead." );if (ints[0 ] >1 ) { delay = ints[2 ]; }
============================[cut here]==========================
drivers/char/tipar.c +11 -5
@@ -67,7 +67,7 @@/* * Version Information */ -#define DRIVER_VERSION "1.17" +#define DRIVER_VERSION "1.19"#define DRIVER_AUTHOR "Romain Lievin <[email protected]>"#define DRIVER_DESC "Device driver for TI/PC parallel link cables"#define DRIVER_LICENSE "GPL"
@@ -361,10 +361,13 @@switch (cmd) {case IOCTL_TIPAR_DELAY : - delay = (int )arg;//get_user(delay, &arg); -break ; + delay = (int )arg;//get_user(delay, &arg); +break ;case IOCTL_TIPAR_TIMEOUT : - timeout = (int )arg;//get_user(timeout, &arg); +if (arg !=0 ) + timeout = (int )arg; +else + retval = -EINVAL ;break ;default : retval = -ENOTTY ;
@@ -399,7 +402,10 @@ str =get_options (str,ARRAY_SIZE (ints), ints);if (ints[0 ] >0 ) { - timeout = ints[1 ]; +if (ints[1 ] !=0 ) + timeout = ints[1 ]; +else +printk ("tipar: wrong timeout value (0), using default value instead." );if (ints[0 ] >1 ) { delay = ints[2 ]; }
Signature · 3 lines
Romain Liévin (roms): <[email protected]> Web site: http://www.lievin.net "Linux, y'a moins bien mais c'est plus cher !"
Greg KH
AppliedQuoted 7 lines · Romain Lievin
Hi,
a set of 2 patches (2.4 & 2.6) about the
tipar.cchar driver. It fixes a divide-by-zero error when we try to read/write data after setting timeout to 0.Please apply...
Applied to 2.6, thanks.
greg k-h