diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2017-06-09 12:59:09 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-09 13:08:27 +0300 |
commit | 666d6a36234f3123e909165ac32ea692213f0155 (patch) | |
tree | 8ffb624c19c19f3ffe806facbd0f7a464bc7ed9c /drivers/nvmem | |
parent | 79fbf0468b2a05a743d31794423925d229c0e9c2 (diff) | |
download | linux-666d6a36234f3123e909165ac32ea692213f0155.tar.xz |
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 <hkallweit1@gmail.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r-- | drivers/nvmem/core.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 0cbac71195b5..4c49285168fb 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -287,9 +287,15 @@ static struct nvmem_cell *nvmem_find_cell(const char *cell_id) { struct nvmem_cell *p; + mutex_lock(&nvmem_cells_mutex); + list_for_each_entry(p, &nvmem_cells, node) - if (p && !strcmp(p->name, cell_id)) + if (p && !strcmp(p->name, cell_id)) { + mutex_unlock(&nvmem_cells_mutex); return p; + } + + mutex_unlock(&nvmem_cells_mutex); return NULL; } |