From ebbb6ea7a2d5bcbc90e48b26f8c3ffb71b1c86ce Mon Sep 17 00:00:00 2001 From: Santosh Reddy Galma Date: Mon, 19 Jun 2023 15:33:38 +0000 Subject: [PATCH] platform: tegra: dce: fix coverity defect - check the handle is valid before retrieving the client structure for the handle during client unregister. Bug 3952896 Change-Id: I6f37625e01453055fb4dc256cffb1f85f199aa36 Signed-off-by: Santosh Reddy Galma Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2922622 Reviewed-by: Mahesh Kumar Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: Arun Swain GVS: Gerrit_Virtual_Submit --- drivers/platform/tegra/dce/dce-client-ipc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/platform/tegra/dce/dce-client-ipc.c b/drivers/platform/tegra/dce/dce-client-ipc.c index 2479597a..b01eaad8 100644 --- a/drivers/platform/tegra/dce/dce-client-ipc.c +++ b/drivers/platform/tegra/dce/dce-client-ipc.c @@ -203,7 +203,11 @@ int tegra_dce_unregister_ipc_client(u32 handle) { struct tegra_dce_client_ipc *cl; - cl = &client_handles[client_handle_to_index(handle)]; + cl = dce_client_ipc_lookup_handle(handle); + if (cl == NULL) { + return -EINVAL; + } + dce_cond_destroy(&cl->recv_wait); return dce_client_ipc_handle_free(handle);