summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2014-05-01 17:38:23 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-03 20:08:56 -0400
commit7d52477ef5e66a43fe54e5737179e4e670db260d (patch)
tree7d23a531c4243a4520bd7a2dcdc385a09b79c631
parenta1f6c2afed3f4c96194f131373b1e914b285c76b (diff)
staging: comedi: drivers: correct mode check for i8254_set_mode()
The upper bound check on the `mode` parameter of `i8254_set_mode()` and `i8254_mm_set_mode()` is incorrect. The `mode` parameter value consists of a mode number in the range 0 to 5 in bits 3..1 {represented by the constants `I8254_MODE0` (0 << 1) through to `I8254_MODE5` (2 << 1)} ORed with a BCD/binary flag in bit 0 {represented by the constants `I8254_BINARY` (0) and `I8254_BCD` (1)}. The maximum allowed value ought to be `I8254_MODE5 | I8254_BCD` ((5 << 1) | 1), but is currently `I8254_MODE5 | I8254_BINARY` ((5 << 1) | 0). Fix it. None of the comedi drivers use `I8254_BCD` but some of the low-level drivers allow user-space to configure the counter mode, so all legal values ought to be allowed. However, it's pretty unlikely anyone would want to set the counters to count in BCD (binary coded decimal) so the bug is not that significant. Reported-by: Hartley Sweeten <HartleyS@visionengravers.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/8253.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h
index fb2c9d905723..5829b46b757b 100644
--- a/drivers/staging/comedi/drivers/8253.h
+++ b/drivers/staging/comedi/drivers/8253.h
@@ -291,7 +291,7 @@ static inline int i8254_set_mode(unsigned long base_address,
if (counter_number > 2)
return -1;
- if (mode > (I8254_MODE5 | I8254_BINARY))
+ if (mode > (I8254_MODE5 | I8254_BCD))
return -1;
byte = counter_number << 6;
@@ -311,7 +311,7 @@ static inline int i8254_mm_set_mode(void __iomem *base_address,
if (counter_number > 2)
return -1;
- if (mode > (I8254_MODE5 | I8254_BINARY))
+ if (mode > (I8254_MODE5 | I8254_BCD))
return -1;
byte = counter_number << 6;