Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a06876ad authored by Priyanka Gujjula's avatar Priyanka Gujjula
Browse files

msm: vidc: Handle race condition for accessing session head



During CVP internal session, CVP close done calls for session
clean. session_clean API acquires the device lock and destroys
the cvp hal_session. At the same time, if decoder session is
also in the verge of close, since session_end does not have a
device lock, there is high chance to access corrupted hal_session
values.

Change-Id: I34593e6507da9bad13c6d92faf40c4d790825d39
Signed-off-by: default avatarPriyanka Gujjula <pgujjula@codeaurora.org>
parent 0422bd40
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -2371,18 +2371,20 @@ static int venus_hfi_session_end(void *sess)
	struct venus_hfi_device *device = &venus_hfi_dev;
	struct venus_hfi_device *device = &venus_hfi_dev;
	int rc = 0;
	int rc = 0;


	if (!__is_session_valid(device, session, __func__))
		return -EINVAL;

	mutex_lock(&device->lock);
	mutex_lock(&device->lock);
	if (!__is_session_valid(device, session, __func__)) {
		rc = -EINVAL;
		goto exit;
	}

	if (msm_vidc_fw_coverage) {
	if (msm_vidc_fw_coverage) {
		if (__sys_set_coverage(device, msm_vidc_fw_coverage,
		if (__sys_set_coverage(device, msm_vidc_fw_coverage,
				session->sid))
				session->sid))
			s_vpr_e(session->sid, "Fw_coverage msg ON failed\n");
			s_vpr_e(session->sid, "Fw_coverage msg ON failed\n");
	}
	}
	rc = __send_session_cmd(session, HFI_CMD_SYS_SESSION_END);
	rc = __send_session_cmd(session, HFI_CMD_SYS_SESSION_END);
exit:
	mutex_unlock(&device->lock);
	mutex_unlock(&device->lock);

	return rc;
	return rc;
}
}