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

Commit 984a1a37 authored by Jeya R's avatar Jeya R Committed by Gerrit - the friendly Code Review server
Browse files

msm: adsprpc: null pointer check for sctx



Adding a null pointer for sctx before dereferencing.

Change-Id: If5ed0e94f7d758e5ed47327ef5ce32ea2e9b4d57
Acked-by: default avatarMaitreyi Gupta <maitreyi@qti.qualcomm.com>
Signed-off-by: default avatarJeya R <jeyr@codeaurora.org>
parent da5067ad
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -518,7 +518,7 @@ static inline int64_t *getperfcounter(struct fastrpc_file *fl, int key)
static void fastrpc_buf_free(struct fastrpc_buf *buf, int cache)
{
	struct fastrpc_file *fl = buf == NULL ? NULL : buf->fl;
	int vmid;
	int vmid, err = 0;

	if (!fl)
		return;
@@ -539,6 +539,9 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf, int cache)
		int destVM[1] = {VMID_HLOS};
		int destVMperm[1] = {PERM_READ | PERM_WRITE | PERM_EXEC};

		VERIFY(err, fl->sctx != NULL);
		if (err)
			goto bail;
		if (fl->sctx->smmu.cb)
			buf->phys &= ~((uint64_t)fl->sctx->smmu.cb << 32);
		vmid = fl->apps->channel[fl->cid].vmid;
@@ -551,6 +554,7 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf, int cache)
		dma_free_attrs(fl->sctx->smmu.dev, buf->size, buf->virt,
					buf->phys, buf->dma_attr);
	}
bail:
	kfree(buf);
}

@@ -1048,6 +1052,11 @@ static int fastrpc_buf_alloc(struct fastrpc_file *fl, size_t size,
	buf->flags = rflags;
	buf->raddr = 0;
	buf->remote = 0;
	VERIFY(err, fl && fl->sctx != NULL);
	if (err) {
		err = -EBADR;
		goto bail;
	}
	buf->virt = dma_alloc_attrs(fl->sctx->smmu.dev, buf->size,
				       (dma_addr_t *)&buf->phys,
					   GFP_KERNEL, buf->dma_attr);
@@ -1709,7 +1718,7 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)

		if (map && map->uncached)
			continue;
		if (ctx->fl->sctx->smmu.coherent &&
		if (ctx->fl->sctx && ctx->fl->sctx->smmu.coherent &&
			!(map && (map->attr & FASTRPC_ATTR_NON_COHERENT)))
			continue;
		if (map && (map->attr & FASTRPC_ATTR_COHERENT))
@@ -1817,7 +1826,7 @@ static void inv_args_pre(struct smq_invoke_ctx *ctx)
			continue;
		if (!rpra[i].buf.len)
			continue;
		if (ctx->fl->sctx->smmu.coherent &&
		if (ctx->fl && ctx->fl->sctx && ctx->fl->sctx->smmu.coherent &&
			!(map && (map->attr & FASTRPC_ATTR_NON_COHERENT)))
			continue;
		if (map && (map->attr & FASTRPC_ATTR_COHERENT))
@@ -1871,7 +1880,7 @@ static void inv_args(struct smq_invoke_ctx *ctx)
			continue;
		if (!rpra[i].buf.len)
			continue;
		if (ctx->fl->sctx->smmu.coherent &&
		if (ctx->fl && ctx->fl->sctx && ctx->fl->sctx->smmu.coherent &&
			!(map && (map->attr & FASTRPC_ATTR_NON_COHERENT)))
			continue;
		if (map && (map->attr & FASTRPC_ATTR_COHERENT))
@@ -2416,6 +2425,9 @@ static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl)
	int tgid = 0;

	VERIFY(err, fl->cid >= 0 && fl->cid < NUM_CHANNELS);
	if (err)
		goto bail;
	VERIFY(err, fl->sctx != NULL);
	if (err)
		goto bail;
	VERIFY(err, fl->apps->channel[fl->cid].chan != NULL);
@@ -3667,8 +3679,10 @@ static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
			goto bail;
	}
	VERIFY(err, fl->sctx != NULL);
	if (err)
	if (err) {
		err = -EBADR;
		goto bail;
	}
	*info = (fl->sctx->smmu.enabled ? 1 : 0);
bail:
	return err;