diff options
author | Jeff LaBundy <[email protected]> | 2022-10-22 19:57:00 -0500 |
---|---|---|
committer | Dmitry Torokhov <[email protected]> | 2022-10-24 05:10:00 -0700 |
commit | 2f6fd232978906f6fb054529210b9faec384bd45 (patch) | |
tree | dfc0068f1393517195a1228d9339ec2cfc01428f | |
parent | 99d03b54ef8506771c15deb714396665592f6adf (diff) |
Input: iqs7222 - protect against undefined slider size
Select variants of silicon do not define a default slider size, in
which case the size must be specified in the device tree. If it is
not, the axis's maximum value is reported as 65535 due to unsigned
integer overflow.
To solve this problem, move the existing zero-check outside of the
conditional block that checks whether the property is present.
Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
Signed-off-by: Jeff LaBundy <[email protected]>
Link: https://lore.kernel.org/r/Y1SRXEi7XMlncDWk@nixie71
Signed-off-by: Dmitry Torokhov <[email protected]>
-rw-r--r-- | drivers/input/misc/iqs7222.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c index a5c08b1d9c9b..6af25dfd1d2a 100644 --- a/drivers/input/misc/iqs7222.c +++ b/drivers/input/misc/iqs7222.c @@ -2024,7 +2024,7 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, error = fwnode_property_read_u32(sldr_node, "azoteq,slider-size", &val); if (!error) { - if (!val || val > dev_desc->sldr_res) { + if (val > dev_desc->sldr_res) { dev_err(&client->dev, "Invalid %s size: %u\n", fwnode_get_name(sldr_node), val); return -EINVAL; @@ -2043,6 +2043,13 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222, return error; } + if (!(reg_offset ? sldr_setup[3] + : sldr_setup[2] & IQS7222_SLDR_SETUP_2_RES_MASK)) { + dev_err(&client->dev, "Undefined %s size\n", + fwnode_get_name(sldr_node)); + return -EINVAL; + } + error = fwnode_property_read_u32(sldr_node, "azoteq,top-speed", &val); if (!error) { if (val > (reg_offset ? U16_MAX : U8_MAX * 4)) { |