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

Commit 38a894b4 authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

ion: msm: Correct memory-region of_node reference counting



of_parse_phandle() is used to deduce if a memory region is
associated with a particular device. The call to of_parse_phandle()
internally increments the reference count to the memory region's
of_node, and thus, the caller should reverse that action by
decrementing it via a call to of_node_put().

Change-Id: I80a0ed843312229f277c09fe107e407118a0a473
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent b11b9665
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -327,12 +327,13 @@ static int ion_sc_add_child(struct ion_sc_heap *manager,

	basep = of_get_address(phandle,  0, &size, NULL);
	if (!basep)
		goto out_free;
		goto out_put_phandle;

	base = of_translate_address(phandle, basep);
	if (base == OF_BAD_ADDR)
		goto out_free;
		goto out_put_phandle;

	of_node_put(phandle);
	heap_data.priv = dev;
	heap_data.base = base;
	heap_data.size = size;
@@ -343,16 +344,18 @@ static int ion_sc_add_child(struct ion_sc_heap *manager,
		goto out_free;

	ret = ion_sc_get_dt_token(entry, np, base, size);
	if (ret)
		goto out_free_carveout;
	if (ret) {
		ion_carveout_heap_destroy(entry->heap);
		goto out_free;
	}

	list_add(&entry->list, &manager->children);
	dev_info(dev, "ion_secure_carveout: creating heap@0x%llx, size 0x%llx\n",
		 base, size);
	return 0;

out_free_carveout:
	ion_carveout_heap_destroy(entry->heap);
out_put_phandle:
	of_node_put(phandle);
out_free:
	kfree(entry);
	return -EINVAL;
+2 −1
Original line number Diff line number Diff line
@@ -276,6 +276,7 @@ static void release_reserved_memory_regions(struct ion_platform_heap *heaps,

		if (mem_node)
			release_reserved_memory(dev, mem_node);
		of_node_put(mem_node);
	}
}

@@ -317,12 +318,12 @@ static int msm_ion_get_heap_dt_data(struct device_node *node,
			heap->base = base;
			heap->size = size;
		}
		of_node_put(pnode);
	} else {
		ret = 0;
	}

out:
	of_node_put(pnode);
	WARN(ret, "Failed to parse DT node for heap %s\n", heap->name);
	return ret;
}