Skip to content

Commit

Permalink
interconnect: qcom: qcs404: Walk the list safely on node removal
Browse files Browse the repository at this point in the history
As we will remove items off the list using list_del(), we need to use the
safe version of list_for_each_entry().

Fixes: 5e4e6c4 ("interconnect: qcom: Add QCS404 interconnect provider driver")
Reported-by: Dmitry Osipenko <digetx@gmail.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Cc: <stable@vger.kernel.org> # v5.4
Link: https://lore.kernel.org/r/20191212075332.16202-4-georgi.djakov@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Georgi Djakov authored and Greg Kroah-Hartman committed Dec 12, 2019
1 parent b29b811 commit f39488e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/interconnect/qcom/qcs404.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ static int qnoc_probe(struct platform_device *pdev)
struct icc_provider *provider;
struct qcom_icc_node **qnodes;
struct qcom_icc_provider *qp;
struct icc_node *node;
struct icc_node *node, *tmp;
size_t num_nodes, i;
int ret;

Expand Down Expand Up @@ -494,7 +494,7 @@ static int qnoc_probe(struct platform_device *pdev)

return 0;
err:
list_for_each_entry(node, &provider->nodes, node_list) {
list_for_each_entry_safe(node, tmp, &provider->nodes, node_list) {
icc_node_del(node);
icc_node_destroy(node->id);
}
Expand All @@ -508,9 +508,9 @@ static int qnoc_remove(struct platform_device *pdev)
{
struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
struct icc_provider *provider = &qp->provider;
struct icc_node *n;
struct icc_node *n, *tmp;

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

0 comments on commit f39488e

Please sign in to comment.