2019-12-02 16:23:22

by Georgi Djakov

[permalink] [raw]
Subject: [PATCH v2 2/5] interconnect: qcom: qcs404: Walk the list safely on node removal

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

Fixes: 5e4e6c4d3ae0 ("interconnect: qcom: Add QCS404 interconnect provider driver")
Reported-by: Dmitry Osipenko <[email protected]>
Signed-off-by: Georgi Djakov <[email protected]>
---
drivers/interconnect/qcom/qcs404.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/interconnect/qcom/qcs404.c b/drivers/interconnect/qcom/qcs404.c
index 5e5843e6bd06..9064f6bdaa69 100644
--- a/drivers/interconnect/qcom/qcs404.c
+++ b/drivers/interconnect/qcom/qcs404.c
@@ -405,7 +405,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;

@@ -485,7 +485,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);
}
@@ -499,9 +499,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);
}


2019-12-02 17:39:26

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v2 2/5] interconnect: qcom: qcs404: Walk the list safely on node removal

On Mon 02 Dec 08:21 PST 2019, Georgi Djakov wrote:

> As we will remove items off the list using list_del(), we need to use the
> safe version of list_for_each_entry().
>
> Fixes: 5e4e6c4d3ae0 ("interconnect: qcom: Add QCS404 interconnect provider driver")
> Reported-by: Dmitry Osipenko <[email protected]>
> Signed-off-by: Georgi Djakov <[email protected]>

Reviewed-by: Bjorn Andersson <[email protected]>

> ---
> drivers/interconnect/qcom/qcs404.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/interconnect/qcom/qcs404.c b/drivers/interconnect/qcom/qcs404.c
> index 5e5843e6bd06..9064f6bdaa69 100644
> --- a/drivers/interconnect/qcom/qcs404.c
> +++ b/drivers/interconnect/qcom/qcs404.c
> @@ -405,7 +405,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;
>
> @@ -485,7 +485,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);
> }
> @@ -499,9 +499,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);
> }