From 5065a3b8797add3ba3ae9389639f6a58375aa653 Mon Sep 17 00:00:00 2001 From: Santosh Sakore Date: Wed, 20 Sep 2023 18:10:20 +0530 Subject: [PATCH] msm: adsprpc : Mark tgid_frpc unuse after device unregister In fastrpc_file_free tgid_frpc is marked as unused before device unregister. And current tgid_frpc can be used by to other sessions from same process, which will lead to device register failures. To avoid this scenario, mark tgid_frpc available after device unregister. Change-Id: I6ba77af3a2b6d0d9aa961459dfe2bf163d5aede2 Signed-off-by: Santosh Sakore --- dsp/adsprpc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dsp/adsprpc.c b/dsp/adsprpc.c index 2c289693a9..4c18ec3085 100644 --- a/dsp/adsprpc.c +++ b/dsp/adsprpc.c @@ -5952,13 +5952,15 @@ skip_dump_wait: fl->is_ramdump_pend = false; fl->is_dma_invoke_pend = false; fl->dsp_process_state = PROCESS_CREATE_DEFAULT; - /* Reset the tgid usage to false */ - if (fl->tgid_frpc != -1) - frpc_tgid_usage_array[fl->tgid_frpc] = false; is_locked = false; spin_unlock_irqrestore(&fl->apps->hlock, irq_flags); if (!fl->sctx) { + spin_lock_irqsave(&me->hlock, irq_flags); + /* Reset the tgid usage to false */ + if (fl->tgid_frpc != -1) + frpc_tgid_usage_array[fl->tgid_frpc] = false; + spin_unlock_irqrestore(&me->hlock, irq_flags); kfree(fl); return 0; } @@ -6001,6 +6003,12 @@ skip_dump_wait: if (fl->device && is_driver_closed) device_unregister(&fl->device->dev); + spin_lock_irqsave(&me->hlock, irq_flags); + /* Reset the tgid usage to false */ + if (fl->tgid_frpc != -1) + frpc_tgid_usage_array[fl->tgid_frpc] = false; + spin_unlock_irqrestore(&me->hlock, irq_flags); + VERIFY(err, VALID_FASTRPC_CID(cid)); if (!err && fl->sctx) fastrpc_session_free(&fl->apps->channel[cid], fl->sctx);