Browse Source

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 <[email protected]>
Grace An 3 years ago
parent
commit
b30002d731
1 changed files with 5 additions and 0 deletions
  1. 5 0
      hw_fence/src/msm_hw_fence.c

+ 5 - 0
hw_fence/src/msm_hw_fence.c

@@ -124,6 +124,11 @@ int msm_hw_fence_deregister(void *client_handle)
 	}
 	}
 	hw_fence_client = (struct msm_hw_fence_client *)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");
 	HWFNC_DBG_H("+\n");
 
 
 	/* Free all the allocated resources */
 	/* Free all the allocated resources */