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

Commit 2c7d8bfe authored by Neeti Desai's avatar Neeti Desai
Browse files

msm: ocmem: Check for NULL pointer from get_zone



The get_zone function might return NULL if it is
unable to find the zone for the associated client
id. Add check to prevent NULL pointer dereferencing.

Change-Id: Icfe5ebce03e05a5592042fdf1be747ea7f93ba67
Signed-off-by: default avatarNeeti Desai <neetid@codeaurora.org>
parent 763e35c9
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -640,6 +640,11 @@ static int ocmem_zone_init(struct platform_device *pdev)
	for (i = 0; i < pdata->nr_parts; i++) {
	for (i = 0; i < pdata->nr_parts; i++) {
		struct ocmem_partition *part = &pdata->parts[i];
		struct ocmem_partition *part = &pdata->parts[i];
		zone = get_zone(part->id);
		zone = get_zone(part->id);
		if (!zone) {
			pr_err("Unable to get zone for client %s\n",
						client_names[part->id]);
			return -EBUSY;
		}
		zone->active = false;
		zone->active = false;


		dev_dbg(dev, "Partition %d, start %lx, size %lx for %s\n",
		dev_dbg(dev, "Partition %d, start %lx, size %lx for %s\n",
+2 −0
Original line number Original line Diff line number Diff line
@@ -709,6 +709,8 @@ static int __sched_grow(struct ocmem_req *req, bool can_block)
	struct ocmem_zone *zone = get_zone(owner);
	struct ocmem_zone *zone = get_zone(owner);
	struct ocmem_region *region = NULL;
	struct ocmem_region *region = NULL;


	BUG_ON(!zone);

	matched_region = find_region_match(req->req_start, req->req_end);
	matched_region = find_region_match(req->req_start, req->req_end);
	matched_req = find_req_match(req->req_id, matched_region);
	matched_req = find_req_match(req->req_id, matched_region);