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

Commit 68c7a31e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: msm_bus: Improve defensive checks for adhoc driver"

parents c31b5fd4 b111da74
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ static int gen_lnode(struct device *dev,
	struct msm_bus_node_device_type *cur_dev = NULL;
	int lnode_idx = -1;

	if (!dev)
		goto exit_gen_lnode;

	cur_dev = dev->platform_data;
	if (!cur_dev) {
		MSM_BUS_ERR("%s: Null device ptr", __func__);
@@ -107,6 +110,9 @@ static int gen_lnode(struct device *dev,
		cur_dev->lnode_list = devm_kzalloc(dev,
				sizeof(struct link_node) * NUM_LNODES,
								GFP_KERNEL);
		if (!cur_dev->lnode_list)
			goto exit_gen_lnode;

		lnode = cur_dev->lnode_list;
		cur_dev->num_lnodes = NUM_LNODES;
		lnode_idx = 0;
@@ -225,6 +231,12 @@ static int prune_path(struct list_head *route_list, int dest, int src,
						&bus_node->node_info->
						id,
						msm_bus_device_match_adhoc);

					if (!dest_dev) {
						lnode_hop = -1;
						goto reset_links;
					}

					lnode_hop = gen_lnode(dest_dev,
							search_dev_id,
							lnode_hop);
@@ -696,7 +708,6 @@ static void unregister_client_adhoc(uint32_t cl)
		goto exit_unregister_client;
	}
	client = handle_list.cl_list[cl];
	curr = client->curr;
	pdata = client->pdata;
	if (!pdata) {
		MSM_BUS_ERR("%s: Null pdata passed to unregister\n",
@@ -704,6 +715,12 @@ static void unregister_client_adhoc(uint32_t cl)
		goto exit_unregister_client;
	}

	curr = client->curr;
	if (curr >= pdata->num_usecases) {
		MSM_BUS_ERR("Invalid index Defaulting curr to 0");
		curr = 0;
	}

	MSM_BUS_DBG("%s: Unregistering client %p", __func__, client);

	for (i = 0; i < pdata->usecase->num_paths; i++) {
@@ -713,10 +730,6 @@ static void unregister_client_adhoc(uint32_t cl)
		lnode = client->src_pnode[i];
		cur_clk = client->pdata->usecase[curr].vectors[i].ib;
		cur_bw = client->pdata->usecase[curr].vectors[i].ab;
		if (curr < 0) {
			cur_clk = 0;
			cur_bw = 0;
		}
		remove_path(src, dest, cur_clk, cur_bw, lnode,
						pdata->active_only);
	}
+8 −3
Original line number Diff line number Diff line
@@ -233,8 +233,7 @@ static int flush_clk_data(struct device *node_device, int ctx)

	node = node_device->platform_data;
	if (!node) {
		MSM_BUS_ERR("%s: Unable to find bus device for device %d",
			__func__, node->node_info->id);
		MSM_BUS_ERR("Unable to find bus device");
		ret = -ENODEV;
		goto exit_flush_clk_data;
	}
@@ -282,6 +281,7 @@ exit_flush_clk_data:
	if (node->node_info->is_fab_dev)
		node->cur_clk_hz[ctx] = 0;

	if (nodeclk)
		nodeclk->dirty = 0;
	return ret;
}
@@ -301,6 +301,11 @@ int msm_bus_commit_data(int *dirty_nodes, int ctx, int num_dirty)
						(void *)&dirty_nodes[i],
						msm_bus_device_match_adhoc);

		if (!node_device) {
			MSM_BUS_ERR("Can't find device for %d", dirty_nodes[i]);
			continue;
		}

		ret = flush_bw_data(node_device, ctx);
		if (ret)
			MSM_BUS_ERR("%s: Error flushing bw data for node %d",
+18 −4
Original line number Diff line number Diff line
@@ -252,8 +252,13 @@ static int *get_arr(struct platform_device *pdev,
		return NULL;
	}

	if (!size) {
		*nports = 0;
		return NULL;
	}

	arr = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
	if ((size > 0) && ZERO_OR_NULL_PTR(arr)) {
	if (ZERO_OR_NULL_PTR(arr)) {
		pr_err("Error: Failed to alloc mem for %s\n", prop);
		return NULL;
	}
@@ -287,12 +292,21 @@ static u64 *get_th_params(struct platform_device *pdev,
		return NULL;
	}

	if (!size) {
		*nports = 0;
		return NULL;
	}

	ret_arr = devm_kzalloc(&pdev->dev, (*nports * sizeof(u64)),
							GFP_KERNEL);
	if (ZERO_OR_NULL_PTR(ret_arr)) {
		pr_err("Error: Failed to alloc mem for ret arr %s\n", prop);
		return NULL;
	}

	arr = kzalloc(size, GFP_KERNEL);
	if ((size > 0) && (ZERO_OR_NULL_PTR(arr)
				|| ZERO_OR_NULL_PTR(ret_arr))) {
		pr_err("Error: Failed to alloc mem for %s\n", prop);
	if ((ZERO_OR_NULL_PTR(arr))) {
		pr_err("Error: Failed to alloc temp mem for %s\n", prop);
		return NULL;
	}