[PATCH 3/5] interconnect: qcom: msm8974: Walk the list safely on node removal

From: Georgi Djakov
Date: Thu Nov 28 2019 - 08:34:52 EST


As we will remove items off the list using list_del(), we need to use the
safe version of list_for_each_entry().

Fixes: 4e60a9568dc6 ("interconnect: qcom: add msm8974 driver")
Reported-by: Dmitry Osipenko <digetx@xxxxxxxxx>
Signed-off-by: Georgi Djakov <georgi.djakov@xxxxxxxxxx>
---
drivers/interconnect/qcom/msm8974.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/interconnect/qcom/msm8974.c b/drivers/interconnect/qcom/msm8974.c
index ce599a0c83d9..0a1a8ba6afa7 100644
--- a/drivers/interconnect/qcom/msm8974.c
+++ b/drivers/interconnect/qcom/msm8974.c
@@ -732,7 +732,7 @@ static int msm8974_icc_probe(struct platform_device *pdev)
return 0;

err_del_icc:
- list_for_each_entry(node, &provider->nodes, node_list) {
+ list_for_each_entry_safe(node, &provider->nodes, node_list) {
icc_node_del(node);
icc_node_destroy(node->id);
}
@@ -750,7 +750,7 @@ static int msm8974_icc_remove(struct platform_device *pdev)
struct icc_provider *provider = &qp->provider;
struct icc_node *n;

- list_for_each_entry(n, &provider->nodes, node_list) {
+ list_for_each_entry_safe(n, &provider->nodes, node_list) {
icc_node_del(n);
icc_node_destroy(n->id);
}