From b50e5b65f8b91268f667c2de96eae4b20f80b653 Mon Sep 17 00:00:00 2001 From: Konstantin Makariev Date: Wed, 30 Oct 2019 12:32:35 -0500 Subject: [PATCH] goodix_gtx8_v1430_mmi: fix kernel panic There are 2 failure cases when core data structure gets released and external modules have no knowledge of it. Kernel panics attempting to address memory that was released already. This change ensures core data pointer of external modules structure only valied when device probed successfully. Change-Id: I4d2ddbb9c8010aba113afd5bff56a1496502bcd1 Signed-off-by: Konstantin Makariev Reviewed-on: https://gerrit.mot.com/1446705 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- .../touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c index f1a22a5e0508..b80392f1051b 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1430_mmi/goodix_ts_core.c @@ -2187,9 +2187,10 @@ static int goodix_ts_probe(struct platform_device *pdev) out: if (r) core_data->initialized = 0; - else + else { core_data->initialized = 1; - goodix_modules.core_data = core_data; + goodix_modules.core_data = core_data; + } ts_info("goodix_ts_probe OUT, r:%d", r); /* wakeup ext module register work */ complete_all(&goodix_modules.core_comp); @@ -2201,6 +2202,7 @@ static int goodix_ts_remove(struct platform_device *pdev) struct goodix_ts_core *core_data = platform_get_drvdata(pdev); core_data->initialized = 0; + goodix_ts_unregister_notifier(&core_data->ts_notifier); if (atomic_read(&core_data->ts_esd.esd_on)) goodix_ts_esd_off(core_data); goodix_remove_all_ext_modules(); @@ -2263,5 +2265,6 @@ int goodix_ts_core_release(struct goodix_ts_core *core_data) platform_driver_unregister(&goodix_ts_driver); goodix_ts_dev_release(); + goodix_modules.core_data = NULL; return 0; }