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

Commit f3a39913 authored by Girish Mahadevan's avatar Girish Mahadevan
Browse files

msm: msm_bus: Add checks against bad accesses in rules engine



Add checks to prevent bad accesses in the rules engine module.

Change-Id: Iebd2017ec2799ff63924b57fce8b2fd914f1d9c8
Signed-off-by: default avatarGirish Mahadevan <girishm@codeaurora.org>
parent e33b9fba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -456,6 +456,9 @@ static int msm_bus_apply_rules(struct list_head *list, bool after_clk_commit)
	bool throttle_en = false;

	list_for_each_entry(rule, list, link) {
		if (!rule)
			continue;

		if (rule && (rule->after_clk_commit != after_clk_commit))
			continue;

+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ static int flush_clk_data(struct device *node_device, int ctx)
	}
exit_flush_clk_data:
	/* Reset the aggregated clock rate for fab devices*/
	if (node->node_info->is_fab_dev)
	if (node && node->node_info->is_fab_dev)
		node->cur_clk_hz[ctx] = 0;

	if (nodeclk)
+10 −1
Original line number Diff line number Diff line
@@ -89,6 +89,11 @@ static struct rule_node_info *gen_node(u32 id, void *data)

	if (!node_match) {
		node_match = kzalloc(sizeof(struct rule_node_info), GFP_KERNEL);
		if (!node_match) {
			pr_err("%s: Cannot allocate memory", __func__);
			goto exit_node_match;
		}

		node_match->id = id;
		node_match->cur_rule = -1;
		node_match->num_rules = 0;
@@ -98,6 +103,7 @@ static struct rule_node_info *gen_node(u32 id, void *data)
		RAW_INIT_NOTIFIER_HEAD(&node_match->rule_notify_list);
		pr_debug("Added new node %d to list\n", id);
	}
exit_node_match:
	return node_match;
}

@@ -567,8 +573,10 @@ void msm_rule_unregister(int num_rules, struct bus_rule_type *rule,
	mutex_lock(&msm_bus_rules_lock);
	if (nb) {
		node = get_node(NB_ID, nb);
		if (!node)
		if (!node) {
			pr_err("%s: Can't find node", __func__);
			goto exit_unregister_rule;
		}

		list_for_each_entry_safe(node_rule, node_rule_tmp,
					&node->node_rules, link) {
@@ -608,6 +616,7 @@ void msm_rule_unregister(int num_rules, struct bus_rule_type *rule,
			kfree(node);
		}
	}
exit_unregister_rule:
	mutex_unlock(&msm_bus_rules_lock);
}