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

Commit a610d60e authored by Tatenda Chipeperekwa's avatar Tatenda Chipeperekwa
Browse files

drivers/misc/hdcp: add error handling for failed app initialization



Add error handling code for use cases in which HDCP app initialization
fails and the QSEECOM handle is invalid. This ensures that the HDCP
QSEECOM library can handle these scenarios gracefully.

Change-Id: I6147e01c062848f588019c40b7a3fee6cbfabf19
Signed-off-by: default avatarTatenda Chipeperekwa <tatendac@codeaurora.org>
parent ea68bc8e
Loading
Loading
Loading
Loading
+33 −10
Original line number Diff line number Diff line
@@ -137,10 +137,14 @@
	((((maj) & 0xFF) << 16) | (((min) & 0xFF) << 8) | ((patch) & 0xFF))

#define hdcp2_app_init_var(x) \
	struct hdcp_##x##_req *req_buf = \
		(struct hdcp_##x##_req *) handle->qseecom_handle->sbuf; \
	struct hdcp_##x##_rsp *rsp_buf = \
		(struct hdcp_##x##_rsp *) (handle->qseecom_handle->sbuf + \
	struct hdcp_##x##_req *req_buf = NULL; \
	struct hdcp_##x##_rsp *rsp_buf = NULL; \
	if (!handle->qseecom_handle) { \
		pr_err("invalid qseecom_handle while processing %s\n", #x); \
		return -EINVAL; \
	} \
	req_buf = (struct hdcp_##x##_req *) handle->qseecom_handle->sbuf; \
	rsp_buf = (struct hdcp_##x##_rsp *) (handle->qseecom_handle->sbuf + \
		QSEECOM_ALIGN(sizeof(struct hdcp_##x##_req))); \
	req_buf->commandid = hdcp_cmd_##x

@@ -835,6 +839,7 @@ static int hdcp2_app_session_init(struct hdcp2_handle *handle)

	if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
		pr_err("app not loaded\n");
		rc = -EINVAL;
		goto exit;
	}

@@ -867,12 +872,14 @@ static int hdcp2_app_session_deinit(struct hdcp2_handle *handle)

	if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
		pr_err("app not loaded\n");
		rc = -EINVAL;
		goto exit;
	}

	if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
		/* unload library here */
		pr_err("session not initialized\n");
		rc = -EINVAL;
		goto exit;
	}

@@ -896,12 +903,14 @@ static int hdcp2_app_tx_deinit(struct hdcp2_handle *handle)

	if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
		pr_err("app not loaded\n");
		rc = -EINVAL;
		goto exit;
	}

	if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
		/* unload library here */
		pr_err("txmtr not initialized\n");
		rc = -EINVAL;
		goto exit;
	}

@@ -925,11 +934,13 @@ static int hdcp2_app_start_auth(struct hdcp2_handle *handle)

	if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
		pr_err("session not initialized\n");
		rc = -EINVAL;
		goto exit;
	}

	if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
		pr_err("txmtr not initialized\n");
		rc = -EINVAL;
		goto exit;
	}

@@ -983,14 +994,23 @@ static int hdcp2_app_start(struct hdcp2_handle *handle)
	return rc;
}

static void hdcp2_app_stop(struct hdcp2_handle *handle)
static int hdcp2_app_stop(struct hdcp2_handle *handle)
{
	hdcp2_app_tx_deinit(handle);
	int rc = 0;

	if (!handle->legacy_app)
		hdcp2_app_session_deinit(handle);
	rc = hdcp2_app_tx_deinit(handle);
	if (rc)
		goto end;

	hdcp2_app_unload(handle);
	if (!handle->legacy_app) {
		rc = hdcp2_app_session_deinit(handle);
		if (rc)
			goto end;
	}

	rc = hdcp2_app_unload(handle);
end:
	return rc;
}

static int hdcp2_app_process_msg(struct hdcp2_handle *handle)
@@ -1128,11 +1148,14 @@ int hdcp2_app_comm(void *ctx, enum hdcp2_app_cmd cmd,
		rc = hdcp2_app_query_stream(handle);
		break;
	case HDCP2_CMD_STOP:
		hdcp2_app_stop(handle);
		rc = hdcp2_app_stop(handle);
	default:
		goto exit;
	}

	if (rc)
		goto exit;

	handle->app_data.request.data = hdcp2_get_recv_buf(handle);

	app_data->request.data = handle->app_data.request.data;