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

Commit 17ec0b84 authored by Liam Mark's avatar Liam Mark
Browse files

staging: android: ion: Validate hyp assign number of elements



Ensure that when we are calling hyp_assign_table that the source and
destination vmid lists each contain at least one vmid since that is
required by hyp_assign.

Change-Id: Ib9d95b3b8333723e40a0027dc54e770eb792b30f
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
parent f64ad702
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -103,6 +103,13 @@ int ion_hyp_unassign_sg(struct sg_table *sgt, int *source_vm_list,
	struct scatterlist *sg;
	int ret, i;

	if (source_nelems <= 0) {
		pr_err("%s: source_nelems invalid\n",
		       __func__);
		ret = -EINVAL;
		goto out;
	}

	ret = hyp_assign_table(sgt, source_vm_list, source_nelems,
			       &dest_vmid, &dest_perms, 1);
	if (ret) {
@@ -126,6 +133,13 @@ int ion_hyp_assign_sg(struct sg_table *sgt, int *dest_vm_list,
	int i;
	int ret = 0;

	if (dest_nelems <= 0) {
		pr_err("%s: dest_nelems invalid\n",
		       __func__);
		ret = -EINVAL;
		goto out;
	}

	dest_perms = kcalloc(dest_nelems, sizeof(*dest_perms), GFP_KERNEL);
	if (!dest_perms) {
		ret = -ENOMEM;