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

Commit 4eaf155c authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qseecom: Release ion buffer in case of keymaster TA"

parents 16839e95 cb4872d6
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -3153,6 +3153,30 @@ static int qseecom_prepare_unload_app(struct qseecom_dev_handle *data)
	pr_debug("prepare to unload app(%d)(%s), pending %d\n",
		data->client.app_id, data->client.app_name,
		data->client.unload_pending);

	/* For keymaster we are not going to unload so no need to add it in
	 * unload app pending list as soon as we identify release ion buffer
	 * and return .
	 */
	if (!memcmp(data->client.app_name, "keymaste", strlen("keymaste"))) {
		if (data->client.dmabuf) {
			/* Each client will get same KM TA loaded handle but
			 * will allocate separate shared buffer during
			 * loading of TA, as client can't unload KM TA so we
			 * will only free out shared buffer and return early
			 * to avoid any ion buffer leak.
			 */
			qseecom_vaddr_unmap(data->client.sb_virt,
				data->client.sgt, data->client.attach,
				data->client.dmabuf);
			MAKE_NULL(data->client.sgt,
				data->client.attach, data->client.dmabuf);
		}
		__qseecom_free_tzbuf(&data->sglistinfo_shm);
		data->released = true;
		return 0;
	}

	if (data->client.unload_pending)
		return 0;
	entry = kzalloc(sizeof(*entry), GFP_KERNEL);