msm: adsprpc: Validate the channel in file free

Validation done for channel id before
dereferencing channel mutex.

Change-Id: I957f08f11f8aad188e215320c2b782de775afa02
Acked-by: Krishnaiah Tadakamalla <ktadakam@qti.qualcomm.com>
Signed-off-by: Jeya R <jeyr@codeaurora.org>
This commit is contained in:
Jeya R 2021-09-14 07:58:25 -07:00
parent 3f69c1ff10
commit 8170fda2e0

View File

@ -5421,6 +5421,7 @@ static int fastrpc_file_free(struct fastrpc_file *fl)
int cid;
struct fastrpc_apps *me = &gfa;
bool is_driver_closed = false;
int err = 0;
if (!fl)
return 0;
@ -5498,9 +5499,10 @@ static int fastrpc_file_free(struct fastrpc_file *fl)
device_unregister(&fl->device->dev);
}
if (fl->sctx)
VERIFY(err, VALID_FASTRPC_CID(fl->cid));
if (!err && fl->sctx)
fastrpc_session_free(&fl->apps->channel[cid], fl->sctx);
if (fl->secsctx)
if (!err && fl->secsctx)
fastrpc_session_free(&fl->apps->channel[cid], fl->secsctx);
fastrpc_remote_buf_list_free(fl);