From ae15646b51cf9514f3a70fb7e97e4538eaee12d7 Mon Sep 17 00:00:00 2001 From: Kamati Srinivas Date: Tue, 16 Apr 2024 15:15:41 +0530 Subject: [PATCH] remoteproc: pas: Cleanup soccp panic notifier Register soccp panic notifier at the end of probe to avoid use after free issues during probe deferral. Unregister it during module unload. Change-Id: I14c146cd1d28c15575b0a3d1b1b7f472e1ae2e30 Signed-off-by: Kamati Srinivas --- drivers/remoteproc/qcom_q6v5_pas.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c index b24c5a20623e..657af4ed3691 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -1649,10 +1649,6 @@ static int adsp_probe(struct platform_device *pdev) mutex_init(&adsp->adsp_lock); adsp->current_users = 0; - - adsp->panic_blk.priority = INT_MAX - 1; - adsp->panic_blk.notifier_call = rproc_panic_handler; - atomic_notifier_chain_register(&panic_notifier_list, &adsp->panic_blk); } qcom_q6v5_register_ssr_subdev(&adsp->q6v5, &adsp->ssr_subdev.subdev); @@ -1699,6 +1695,12 @@ static int adsp_probe(struct platform_device *pdev) } mutex_unlock(&q6v5_pas_mutex); + if (adsp->check_status) { + adsp->panic_blk.priority = INT_MAX - 1; + adsp->panic_blk.notifier_call = rproc_panic_handler; + atomic_notifier_chain_register(&panic_notifier_list, &adsp->panic_blk); + } + return 0; remove_rproc: @@ -1741,6 +1743,8 @@ static int adsp_remove(struct platform_device *pdev) qcom_remove_sysmon_subdev(adsp->sysmon); qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev); qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev); + if (adsp->check_status) + atomic_notifier_chain_unregister(&panic_notifier_list, &adsp->panic_blk); adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count); device_init_wakeup(adsp->dev, false); rproc_free(adsp->rproc);