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

Commit db7015b1 authored by Gopikrishnaiah Anandan's avatar Gopikrishnaiah Anandan
Browse files

ASoC: msm: qdsp6v2: Fix invalid params handling



When ion_import_legacy api fails,we should not
call ion_free as the handle returned is not proper to
dereference. Instead just destroy the ion client and
bail out. Sanity checks for all the input params is also
added.

Change-Id: I6c51986bf2ce334ff7405e38a12c1c1db50e2417
Signed-off-by: default avatarGopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: default avatarAnish Kumar <kanish@codeaurora.org>
parent 1fd34fba
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -334,6 +334,11 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr)
{
	int rc = 0;
	if (!name || !client || !handle || !paddr || !vaddr || !pa_len) {
		pr_err("%s: Invalid params\n", __func__);
		rc = -EINVAL;
		goto err;
	}
	/* client is already created for legacy and given*/
	/* name should be audio_acdb_client or Audio_Dec_Client,
	bufsz should be 0 and fd shouldn't be 0 as of now
@@ -344,7 +349,8 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
	if (IS_ERR_OR_NULL((void *)(*handle))) {
		pr_err("%s: ion import dma buffer failed\n",
			__func__);
		goto err_ion_handle;
		rc = -EINVAL;
		goto err_destroy_client;
	}

	if (ionflag != NULL) {
@@ -352,6 +358,7 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
		if (rc) {
			pr_err("%s: could not get flags for the handle\n",
							__func__);
			rc = -EINVAL;
			goto err_ion_handle;
		}
	}
@@ -360,6 +367,7 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
	if (rc) {
		pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
			__func__, rc);
		rc = -EINVAL;
		goto err_ion_handle;
	}

@@ -367,6 +375,7 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,
	*vaddr = ion_map_kernel(client, *handle);
	if (IS_ERR_OR_NULL((void *)*vaddr)) {
		pr_err("%s: ION memory mapping for AUDIO failed\n", __func__);
		rc = -EINVAL;
		goto err_ion_handle;
	}

@@ -377,8 +386,12 @@ int msm_audio_ion_import_legacy(const char *name, struct ion_client *client,

err_ion_handle:
	ion_free(client, *handle);
	return -EINVAL;

err_destroy_client:
	msm_audio_ion_client_destroy(client);
	client = NULL;
	*handle = NULL;
err:
	return rc;
}

int msm_audio_ion_free_legacy(struct ion_client *client,