driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDBQ74 ---------------------------------------------------------------------- SoC cache dev array is under the protection of the spinlock, hence the verification should also be protected. Fixes: e6ecc3b028b8 ("soc cache: Add framework driver for HiSilicon SoC cache") Signed-off-by: Yushan Wang <wangyushan12@huawei.com> Signed-off-by: Hongye Lin <linhongye@h-partners.com> --- drivers/soc/hisilicon/hisi_soc_cache_framework.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_soc_cache_framework.c b/drivers/soc/hisilicon/hisi_soc_cache_framework.c index a45938ae525e..30a2b4148630 100644 --- a/drivers/soc/hisilicon/hisi_soc_cache_framework.c +++ b/drivers/soc/hisilicon/hisi_soc_cache_framework.c @@ -59,12 +59,12 @@ static int hisi_soc_cache_lock(int cpu, phys_addr_t addr, size_t size) struct list_head *head; int ret = -ENOMEM; + guard(spinlock)(&soc_cache_devs[HISI_SOC_L3C].lock); + /* Avoid null pointer when there is no instance onboard. */ if (soc_cache_devs[HISI_SOC_L3C].inst_num <= 0) return ret; - guard(spinlock)(&soc_cache_devs[HISI_SOC_L3C].lock); - /* Iterate L3C instances to perform operation, break loop once found. */ head = &soc_cache_devs[HISI_SOC_L3C].node; list_for_each_entry(inst, head, node) { @@ -92,12 +92,12 @@ static int hisi_soc_cache_unlock(int cpu, phys_addr_t addr) struct list_head *head; int ret = 0; + guard(spinlock)(&soc_cache_devs[HISI_SOC_L3C].lock); + /* Avoid null pointer when there is no instance onboard. */ if (soc_cache_devs[HISI_SOC_L3C].inst_num <= 0) return ret; - guard(spinlock)(&soc_cache_devs[HISI_SOC_L3C].lock); - /* Iterate L3C instances to perform operation, break loop once found. */ head = &soc_cache_devs[HISI_SOC_L3C].node; list_for_each_entry(inst, head, node) { -- 2.33.0