Commit a831ffb5 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: lock area cache earlier

We shouldn't access area_cache_list without its lock even
to check if it's empty.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 61e81abd
...@@ -821,10 +821,7 @@ area_cache_get(struct nfp_cpp *cpp, u32 id, ...@@ -821,10 +821,7 @@ area_cache_get(struct nfp_cpp *cpp, u32 id,
* the need for special case code below when * the need for special case code below when
* checking against available cache size. * checking against available cache size.
*/ */
if (length == 0) if (length == 0 || id == 0)
return NULL;
if (list_empty(&cpp->area_cache_list) || id == 0)
return NULL; return NULL;
/* Remap from cpp_island to cpp_target */ /* Remap from cpp_island to cpp_target */
...@@ -832,10 +829,15 @@ area_cache_get(struct nfp_cpp *cpp, u32 id, ...@@ -832,10 +829,15 @@ area_cache_get(struct nfp_cpp *cpp, u32 id,
if (err < 0) if (err < 0)
return NULL; return NULL;
addr += *offset;
mutex_lock(&cpp->area_cache_mutex); mutex_lock(&cpp->area_cache_mutex);
if (list_empty(&cpp->area_cache_list)) {
mutex_unlock(&cpp->area_cache_mutex);
return NULL;
}
addr += *offset;
/* See if we have a match */ /* See if we have a match */
list_for_each_entry(cache, &cpp->area_cache_list, entry) { list_for_each_entry(cache, &cpp->area_cache_list, entry) {
if (id == cache->id && if (id == cache->id &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment