Re: [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell
On 04/06/17 12:01, Heiner Kallweit wrote: Adding entries to nvmem_cells and deleting entries from it is protected by nvmem_cells_mutex. Therefore this mutex should also protect iterating over the list. Signed-off-by: Heiner Kallweit--- drivers/nvmem/core.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e07f3f8..1aa6d25a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -286,9 +286,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(_cells_mutex); + list_for_each_entry(p, _cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(_cells_mutex); return p; + } + + mutex_unlock(_cells_mutex); Thanks for the patch, I will queue this up. Thanks, srini return NULL; }
Re: [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell
On 04/06/17 12:01, Heiner Kallweit wrote: Adding entries to nvmem_cells and deleting entries from it is protected by nvmem_cells_mutex. Therefore this mutex should also protect iterating over the list. Signed-off-by: Heiner Kallweit --- drivers/nvmem/core.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e07f3f8..1aa6d25a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -286,9 +286,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(_cells_mutex); + list_for_each_entry(p, _cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(_cells_mutex); return p; + } + + mutex_unlock(_cells_mutex); Thanks for the patch, I will queue this up. Thanks, srini return NULL; }
[PATCH 2/3] nvmem: core: add locking to nvmem_find_cell
Adding entries to nvmem_cells and deleting entries from it is protected by nvmem_cells_mutex. Therefore this mutex should also protect iterating over the list. Signed-off-by: Heiner Kallweit--- drivers/nvmem/core.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e07f3f8..1aa6d25a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -286,9 +286,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(_cells_mutex); + list_for_each_entry(p, _cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(_cells_mutex); return p; + } + + mutex_unlock(_cells_mutex); return NULL; } -- 2.13.0
[PATCH 2/3] nvmem: core: add locking to nvmem_find_cell
Adding entries to nvmem_cells and deleting entries from it is protected by nvmem_cells_mutex. Therefore this mutex should also protect iterating over the list. Signed-off-by: Heiner Kallweit --- drivers/nvmem/core.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 4e07f3f8..1aa6d25a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -286,9 +286,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(_cells_mutex); + list_for_each_entry(p, _cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(_cells_mutex); return p; + } + + mutex_unlock(_cells_mutex); return NULL; } -- 2.13.0