mm-drivers: hw_fence: add bounds check for hw fence deregistration

Ensure that clients deregister hardware fences for client ids
strictly less than HW_FENCE_CLIENT_MAX. This prevents out of bounds
array accesses.

Change-Id: I3453135cfd7a74373421d8db32c3ecb0fffc70d0
Signed-off-by: Grace An <quic_gracan@quicinc.com>
This commit is contained in:
Grace An
2022-07-29 14:58:06 -07:00
parent c344a18254
commit b30002d731

View File

@@ -124,6 +124,11 @@ int msm_hw_fence_deregister(void *client_handle)
}
hw_fence_client = (struct msm_hw_fence_client *)client_handle;
if (hw_fence_client->client_id >= HW_FENCE_CLIENT_MAX) {
HWFNC_ERR("Invalid client_id:%d\n", hw_fence_client->client_id);
return -EINVAL;
}
HWFNC_DBG_H("+\n");
/* Free all the allocated resources */