These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / base / cacheinfo.c
index df0c66c..e9fd32e 100644 (file)
@@ -148,7 +148,11 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
 
                        if (sibling == cpu) /* skip itself */
                                continue;
+
                        sib_cpu_ci = get_cpu_cacheinfo(sibling);
+                       if (!sib_cpu_ci->info_list)
+                               continue;
+
                        sib_leaf = sib_cpu_ci->info_list + index;
                        cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map);
                        cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map);
@@ -159,6 +163,9 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
 
 static void free_cache_attributes(unsigned int cpu)
 {
+       if (!per_cpu_cacheinfo(cpu))
+               return;
+
        cache_shared_cpu_map_remove(cpu);
 
        kfree(per_cpu_cacheinfo(cpu));
@@ -191,12 +198,12 @@ static int detect_cache_attributes(unsigned int cpu)
        if (ret)
                goto free_ci;
        /*
-        * For systems using DT for cache hierarcy, of_node and shared_cpu_map
+        * For systems using DT for cache hierarchy, of_node and shared_cpu_map
         * will be set up here only if they are not populated already
         */
        ret = cache_shared_cpu_map_setup(cpu);
        if (ret) {
-               pr_warn("Unable to detect cache hierarcy from DT for CPU %d\n",
+               pr_warn("Unable to detect cache hierarchy from DT for CPU %d\n",
                        cpu);
                goto free_ci;
        }
@@ -514,8 +521,7 @@ static int cacheinfo_cpu_callback(struct notifier_block *nfb,
                break;
        case CPU_DEAD:
                cache_remove_dev(cpu);
-               if (per_cpu_cacheinfo(cpu))
-                       free_cache_attributes(cpu);
+               free_cache_attributes(cpu);
                break;
        }
        return notifier_from_errno(rc);