Input: elants_i2c - fix division by zero if firmware reports zero phys size
authorDmitry Osipenko <digetx@gmail.com>
Fri, 26 Mar 2021 22:19:27 +0000 (15:19 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 28 Mar 2021 04:41:09 +0000 (21:41 -0700)
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 <jja2000@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210302100824.3423-1-digetx@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/elants_i2c.c

index 4c2b579f6c8bf35a07a22ca0d95db620defff79a..78172c31529a4e4b9d0bd949fb31603e7334c301 100644 (file)
@@ -1441,7 +1441,7 @@ 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);