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

Commit 8c87da43 authored by Mohammed Javid's avatar Mohammed Javid
Browse files

msm: ipa: fix to not allow NAT DMA command without device initialization



Without NAT device initialization sending NAT DMA
commands leads to XPU violation. Added checks to
verify device initialized or not before sending DMA
command.

Change-Id: I7440abc14a81e1621573f0e2808a410d60b2458d
Acked-by: default avatarAshok Vuyyuru <avuyyuru@qti.qualcomm.com>
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent 202aa1fb
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -327,6 +327,11 @@ int ipa2_nat_init_cmd(struct ipa_ioc_v4_nat_init *init)
	size_t tmp;
	gfp_t flag = GFP_KERNEL | (ipa_ctx->use_dma_zone ? GFP_DMA : 0);

	if (!ipa_ctx->nat_mem.is_dev_init) {
		IPAERR_RL("Nat table not initialized\n");
		return -EPERM;
	}

	IPADBG("\n");
	if (init->table_entries == 0) {
		IPADBG("Table entries is zero\n");
@@ -576,6 +581,11 @@ int ipa2_nat_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
	int ret = 0;
	gfp_t flag = GFP_KERNEL | (ipa_ctx->use_dma_zone ? GFP_DMA : 0);

	if (!ipa_ctx->nat_mem.is_dev_init) {
		IPAERR_RL("Nat table not initialized\n");
		return -EPERM;
	}

	IPADBG("\n");
	if (dma->entries <= 0) {
		IPAERR_RL("Invalid number of commands %d\n",
@@ -762,6 +772,16 @@ int ipa2_nat_del_cmd(struct ipa_ioc_v4_nat_del *del)
	int result;
	gfp_t flag = GFP_KERNEL | (ipa_ctx->use_dma_zone ? GFP_DMA : 0);

	if (!ipa_ctx->nat_mem.is_dev_init) {
		IPAERR_RL("Nat table not initialized\n");
		return -EPERM;
	}

	if (ipa_ctx->nat_mem.public_ip_addr) {
		IPAERR_RL("Public IP addr not assigned and trying to delete\n");
		return -EPERM;
	}

	IPADBG("\n");
	if (ipa_ctx->nat_mem.is_tmp_mem) {
		IPAERR("using temp memory during nat del\n");
+5 −0
Original line number Diff line number Diff line
@@ -1258,6 +1258,11 @@ int ipa3_table_dma_cmd(struct ipa_ioc_nat_dma_cmd *dma)
		goto bail;
	}

	if (!ipa3_ctx->nat_mem.dev.is_dev_init) {
		IPAERR_RL("NAT hasn't been initialized\n");
		return -EPERM;
	}

	for (cnt = 0; cnt < dma->entries; ++cnt) {
		result = ipa3_table_validate_table_dma_one(&dma->dma[cnt]);
		if (result) {