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

Commit 91dd610e authored by Zhen Kong's avatar Zhen Kong
Browse files

qseecom: Change mutex operation for qseecom_unload_app



qseecom_unload_app is protected between global mutex lock/unlock.
And it will wait until all other ioctl functions related to the
same process are finished, then unload app.
When reentrancy is enabled and mutex is hold during sleep, another
cmd for the same app that tries to grab mutex may cause deadlock.
So we make change to unlock mutex before sleep and re-locked it
again after wake up.

Change-Id: I60eca546ba82e7261296202f941a416be5f898df
Signed-off-by: default avatarZhen Kong <zkong@codeaurora.org>
parent 50e0173f
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1903,17 +1903,21 @@ enable_clk_err:

static int __qseecom_cleanup_app(struct qseecom_dev_handle *data)
{
	int ret = 1;	/* Set unload app */
	wake_up_all(&qseecom.send_resp_wq);
	if (qseecom.qsee_reentrancy_support)
		mutex_unlock(&app_access_lock);
	while (atomic_read(&data->ioctl_count) > 1) {
		if (wait_event_freezable(data->abort_wq,
					atomic_read(&data->ioctl_count) <= 1)) {
			pr_err("Interrupted from abort\n");
			return -ERESTARTSYS;
			ret = -ERESTARTSYS;
			break;
		}
	}
	/* Set unload app */
	return 1;
	if (qseecom.qsee_reentrancy_support)
		mutex_lock(&app_access_lock);
	return ret;
}

static int qseecom_unmap_ion_allocated_memory(struct qseecom_dev_handle *data)
@@ -7051,7 +7055,9 @@ static int qseecom_remove(struct platform_device *pdev)
			goto exit_free_kc_handle;

		list_del(&kclient->list);
		mutex_lock(&app_access_lock);
		ret = qseecom_unload_app(kclient->handle->dev, false);
		mutex_unlock(&app_access_lock);
		if (!ret) {
			kzfree(kclient->handle->dev);
			kzfree(kclient->handle);