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

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

Merge "msm: adsprpc: null pointer check for sctx"

parents ab043d32 67e94335
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -504,7 +504,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;
	struct fastrpc_apps *me = &gfa;

	if (!fl)
@@ -526,6 +526,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 && fl->cid != SDSP_DOMAIN_ID)
			buf->phys &= ~((uint64_t)fl->sctx->smmu.cb << 32);
		vmid = fl->apps->channel[fl->cid].vmid;
@@ -538,6 +541,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);
}

@@ -1034,6 +1038,12 @@ 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);
@@ -1671,7 +1681,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))
@@ -1775,7 +1785,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))
@@ -1827,7 +1837,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))
@@ -3456,8 +3466,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;