]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Input: edt-ft5x06 - fix regmap leak when probe fails
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Sat, 19 Oct 2024 00:17:48 +0000 (17:17 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 25 Oct 2024 01:38:07 +0000 (18:38 -0700)
commitbffdf9d7e51a7be8eeaac2ccf9e54a5fde01ff65
tree1564ea5cedcb5f5d5e425a81381762d6ed88fbb6
parent2de01e0e57f3ebe7f90b08f6bca5ce0f3da3829f
Input: edt-ft5x06 - fix regmap leak when probe fails

The driver neglects to free the instance of I2C regmap constructed at
the beginning of the edt_ft5x06_ts_probe() method when probe fails.
Additionally edt_ft5x06_ts_remove() is freeing the regmap too early,
before the rest of the device resources that are managed by devm are
released.

Fix this by installing a custom devm action that will ensure that the
regmap is released at the right time during normal teardown as well as
in case of probe failure.

Note that devm_regmap_init_i2c() could not be used because the driver
may replace the original regmap with a regmap specific for M06 devices
in the middle of the probe, and using devm_regmap_init_i2c() would
result in releasing the M06 regmap too early.

Reported-by: Li Zetao <lizetao1@huawei.com>
Fixes: 9dfd9708ffba ("Input: edt-ft5x06 - convert to use regmap API")
Cc: stable@vger.kernel.org
Reviewed-by: Oliver Graute <oliver.graute@kococonnector.com>
Link: https://lore.kernel.org/r/ZxL6rIlVlgsAu-Jv@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/edt-ft5x06.c