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

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

Merge "msm: adsprpc: protect access of context table for all respnose type"

parents ceb3c166 9ea1ae52
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -3463,10 +3463,9 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
	struct smq_invoke_rspv2 *rspv2 = NULL;
	struct fastrpc_apps *me = &gfa;
	uint32_t index, rspFlags = 0, earlyWakeTime = 0;
	int err = 0, cid;
	struct fastrpc_channel_ctx *chan = 0;
	int err = 0, cid = -1;
	struct fastrpc_channel_ctx *chan = NULL;
	unsigned long irq_flags = 0;
	bool is_ctxtable_locked = false;

	cid = get_cid_from_rpdev(rpdev);
	VERIFY(err, (cid >= ADSP_DOMAIN_ID && cid <= NUM_CHANNELS));
@@ -3500,31 +3499,28 @@ static int fastrpc_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
	if (err)
		goto bail;

	if (rspFlags == COMPLETE_SIGNAL) {
	spin_lock_irqsave(&chan->ctxlock, irq_flags);
		is_ctxtable_locked = true;
	}
	VERIFY(err, !IS_ERR_OR_NULL(chan->ctxtable[index]));
	if (err)
		goto bail;
		goto bail_unlock;

	VERIFY(err, ((chan->ctxtable[index]->ctxid ==
		(rsp->ctx & ~CONTEXT_PD_CHECK)) &&
			chan->ctxtable[index]->magic ==
				FASTRPC_CTX_MAGIC));
	if (err)
		goto bail;
		goto bail_unlock;

	if (rspv2) {
		VERIFY(err, rspv2->version == FASTRPC_RSP_VERSION2);
		if (err)
			goto bail;
			goto bail_unlock;
	}
	context_notify_user(chan->ctxtable[index], rsp->retval,
				 rspFlags, earlyWakeTime);
bail:
	if (rspFlags == COMPLETE_SIGNAL && is_ctxtable_locked)
bail_unlock:
	spin_unlock_irqrestore(&chan->ctxlock, irq_flags);
bail:
	if (err)
		pr_err("adsprpc: ERROR: %s: invalid response (data %pK, len %d) from remote subsystem (err %d)\n",
				__func__, data, len, err);