Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1659936

Re: [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell

From Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell
Date 2017-06-07 17:40 +0200
Message-ID <tPLdT-8rQ-13@gated-at.bofh.it> (permalink)
References <tOBgB-3Og-13@gated-at.bofh.it> <tOBzX-4bP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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 <hkallweit1@gmail.com>
> ---
>  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(&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);
>
Thanks for the patch, I will queue this up.

Thanks,
srini
>  	return NULL;
>  }
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] nvmem: core: series with smaller refactorings Heiner Kallweit <hkallweit1@gmail.com> - 2017-06-04 12:50 +0200
  [PATCH 1/3] nvmem: core: remove member users from struct nvmem_device Heiner Kallweit <hkallweit1@gmail.com> - 2017-06-04 13:10 +0200
    Re: [PATCH 1/3] nvmem: core: remove member users from struct  nvmem_device Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-06-07 17:40 +0200
      Re: [PATCH 1/3] nvmem: core: remove member users from struct  nvmem_device Heiner Kallweit <hkallweit1@gmail.com> - 2017-06-08 00:00 +0200
        Re: [PATCH 1/3] nvmem: core: remove member users from struct  nvmem_device Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-06-08 08:40 +0200
  [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell Heiner Kallweit <hkallweit1@gmail.com> - 2017-06-04 13:10 +0200
    Re: [PATCH 2/3] nvmem: core: add locking to nvmem_find_cell Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2017-06-07 17:40 +0200
  [PATCH 3/3] nvmem: core: remove nvmem_mutex Heiner Kallweit <hkallweit1@gmail.com> - 2017-06-04 13:10 +0200

csiph-web