From d37fe0868ccc3d36d39f8d3dc377a62edc8e5682 Mon Sep 17 00:00:00 2001 From: Jyothi Kumar Seerapu Date: Thu, 23 Feb 2023 12:06:58 +0530 Subject: [PATCH] pci: msm: Flush workqueue and destroy it in mhi controller unregister In mhi_unregister_mhi_controller function, flush the work queue and then destroy it for releasing the memory of unused workqueues. When multiple mhi-based WLAN endpoints are attached directly or over switch, then there can be multiple mhi controllers and so CNSS driver calls for mhi controller registration multiple times. Each time invoking mhi controller register creates another set of workqueues and previous workqueues become stale. By doing so, it will consume the system memory. So, better to release the memory assigned to workqueue by destroying the work queue in mhi_unregister_mhi_controller function. Change-Id: I838371e9c00969a64e658e6175115363ccb916bf Signed-off-by: Jyothi Kumar Seerapu --- drivers/bus/mhi/core/mhi_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/bus/mhi/core/mhi_init.c b/drivers/bus/mhi/core/mhi_init.c index 60ae6c51143c..e2827e4e1498 100644 --- a/drivers/bus/mhi/core/mhi_init.c +++ b/drivers/bus/mhi/core/mhi_init.c @@ -1743,6 +1743,8 @@ void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl) struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev; struct mhi_sfr_info *sfr_info = mhi_cntrl->mhi_sfr; + destroy_workqueue(mhi_cntrl->wq); + kfree(mhi_cntrl->mhi_cmd); kfree(mhi_cntrl->mhi_event); vfree(mhi_cntrl->mhi_chan);