From f1441eef721eba3cc7bbf0147db2f341e5a6bc4f Mon Sep 17 00:00:00 2001 From: David Dai Date: Thu, 14 Nov 2019 15:40:51 -0800 Subject: [PATCH] interconnect: qcom: Prevent duplicate BCMs being added to commit list Having the same node being added to bcm voter commit list will result in an infinite loop when walking through the list. Prevent the same node from being added multiple times by checking bcm->list and clean up commit list after sending the commands to RPMh. Change-Id: Ie210437df43efd537bdcb0143b03423964ac3840 Signed-off-by: David Dai --- drivers/interconnect/qcom/bcm-voter.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c index bfcddf697a50..b791181dfe6d 100644 --- a/drivers/interconnect/qcom/bcm-voter.c +++ b/drivers/interconnect/qcom/bcm-voter.c @@ -211,7 +211,8 @@ void qcom_icc_bcm_voter_add(struct bcm_voter *voter, struct qcom_icc_bcm *bcm) return; mutex_lock(&voter->lock); - list_add_tail(&bcm->list, &voter->commit_list); + if (list_empty(&bcm->list)) + list_add_tail(&bcm->list, &voter->commit_list); if (list_empty(&bcm->ws_list)) list_add_tail(&bcm->ws_list, &voter->ws_list); @@ -280,6 +281,9 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter) goto out; } + list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list) + list_del_init(&bcm->list); + INIT_LIST_HEAD(&voter->commit_list); list_for_each_entry_safe(bcm, bcm_tmp, &voter->ws_list, ws_list) { @@ -322,6 +326,9 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter) } out: + list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list) + list_del_init(&bcm->list); + INIT_LIST_HEAD(&voter->commit_list); mutex_unlock(&voter->lock); return ret;