Input: elants_i2c - fix division by zero if firmware reports zero phys size
Subsystems (3)
PATCH 1/1 Input: elants_i2c - fix division by zero if firmware reports zero phys size
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys size. Hence check whether the size is zero and don't set the resolution in this case.
---
Please note that ASUS TF700T isn't yet supported by upstream kernel, hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/input/touchscreen/elants_i2c.c +5 -3
@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,touchscreen_parse_properties (ts->input, true, &ts->prop); -if (ts->chip_id ==EKTF3624 ) { +if (ts->chip_id ==EKTF3624 && ts->phy_x && ts->phy_y) {/* calculate resolution from size */ ts->x_res =DIV_ROUND_CLOSEST (ts->prop.max_x, ts->phy_x); ts->y_res =DIV_ROUND_CLOSEST (ts->prop.max_y, ts->phy_y); } -input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); -input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res); +if (ts->x_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); +if (ts->y_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);if (ts->major_res >0 )input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR , ts->major_res);
Signature · 1 line
2.29.2
Quoted 7 lines · Dmitry Osipenko
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys size. Hence check whether the size is zero and don't set the resolution in this case.
Reported-by Jasper Korten <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>---
Quoted 17 lines
Please note that ASUS TF700T isn't yet supported by upstream kernel, hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/input/touchscreen/elants_i2c.c +1
-1@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,touchscreen_parse_properties (ts->input, true, &ts->prop); -if (ts->chip_id ==EKTF3624 ) { +if (ts->chip_id ==EKTF3624 && ts->phy_x && ts->phy_y) {/* calculate resolution from size */
drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1453
Quoted 10 lines
drivers/input/touchscreen/elants_i2c.c +4
-2ts->x_res =DIV_ROUND_CLOSEST (ts->prop.max_x, ts->phy_x); ts->y_res =DIV_ROUND_CLOSEST (ts->prop.max_y, ts->phy_y); } -input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); -input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res); +if (ts->x_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); +if (ts->y_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);
I would guess that you can tie X and Y in one if, as they are unlikely to work independently.
Best Regards
Michal Mirosław
02.03.2021 13:08, Dmitry Osipenko пишет:
Quoted 29 lines
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys size. Hence check whether the size is zero and don't set the resolution in this case.
Reported-by Jasper Korten <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>---
Please note that ASUS TF700T isn't yet supported by upstream kernel, hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/input/touchscreen/elants_i2c.c +1
-1@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,touchscreen_parse_properties (ts->input, true, &ts->prop); -if (ts->chip_id ==EKTF3624 ) { +if (ts->chip_id ==EKTF3624 && ts->phy_x && ts->phy_y) {/* calculate resolution from size */ ts->x_res =DIV_ROUND_CLOSEST (ts->prop.max_x, ts->phy_x); ts->y_res =DIV_ROUND_CLOSEST (ts->prop.max_y, ts->phy_y); }
drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1456
Quoted 10 lines
drivers/input/touchscreen/elants_i2c.c +4
-2-input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); -input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res); +if (ts->x_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); +if (ts->y_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);if (ts->major_res >0 )input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR , ts->major_res);
Hi,
This is a very minor fix, but still will be nice if we could get it into 5.13 in order to have one less patch to care about. Thanks in advance!
Dmitry Torokhov
maintainerHi Dmitry,
Quoted 23 lines · Dmitry Osipenko
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys size. Hence check whether the size is zero and don't set the resolution in this case.
Reported-by Jasper Korten <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>---
Please note that ASUS TF700T isn't yet supported by upstream kernel, hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/input/touchscreen/elants_i2c.c +0
-1@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,touchscreen_parse_properties (ts->input, true, &ts->prop); -if (ts->chip_id ==EKTF3624 ) {
drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1451
Quoted 10 lines
drivers/input/touchscreen/elants_i2c.c +3
-2+if (ts->chip_id ==EKTF3624 && ts->phy_x && ts->phy_y) {/* calculate resolution from size */ ts->x_res =DIV_ROUND_CLOSEST (ts->prop.max_x, ts->phy_x); ts->y_res =DIV_ROUND_CLOSEST (ts->prop.max_y, ts->phy_y); } -input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); -input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res); +if (ts->x_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res);
There is absolutely no difference between setting respluton to 0 vs not setting it at all, so I dropped the conditionals and applied.
drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1454
Quoted 3 lines
drivers/input/touchscreen/elants_i2c.c +2
-0+if (ts->y_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);if (ts->major_res >0 )
We could drop this condition as well.
Quoted 5 lines
drivers/input/touchscreen/elants_i2c.c +0
-0input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR , ts->major_res);Signature · 1 line
2.29.2
Thanks.
Signature · 1 line
Dmitry
28.03.2021 07:44, Dmitry Torokhov пишет:
Quoted 40 lines
Hi Dmitry,
Quoted 23 lines · Dmitry Osipenko
Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys size. Hence check whether the size is zero and don't set the resolution in this case.
Reported-by Jasper Korten <[email protected]>Signed-off-by Dmitry Osipenko <[email protected]>---
Please note that ASUS TF700T isn't yet supported by upstream kernel, hence this is not a critical fix.
drivers/input/touchscreen/elants_i2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/input/touchscreen/elants_i2c.c +0
-1@@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client,touchscreen_parse_properties (ts->input, true, &ts->prop); -if (ts->chip_id ==EKTF3624 ) {drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1451
Quoted 10 lines
drivers/input/touchscreen/elants_i2c.c +3
-2+if (ts->chip_id ==EKTF3624 && ts->phy_x && ts->phy_y) {/* calculate resolution from size */ ts->x_res =DIV_ROUND_CLOSEST (ts->prop.max_x, ts->phy_x); ts->y_res =DIV_ROUND_CLOSEST (ts->prop.max_y, ts->phy_y); } -input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res); -input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res); +if (ts->x_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res);There is absolutely no difference between setting respluton to 0 vs not setting it at all, so I dropped the conditionals and applied.
Quoted 7 lines
drivers/input/touchscreen/elants_i2c.c static int elants_i2c_probe(struct i2c_client *client, · line 1454
Quoted 3 lines
drivers/input/touchscreen/elants_i2c.c +2
-0+if (ts->y_res >0 ) +input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);if (ts->major_res >0 )We could drop this condition as well.
Quoted 1 line
drivers/input/touchscreen/elants_i2c.c +0
-0input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR , ts->major_res);
I'll make a follow up patch to clean up this condition, if you haven't done it yet. Thanks!