cpu: fix prevent defect
authorPark Bumgyu <bumgyu.park@samsung.com>
Tue, 24 Jul 2018 04:02:35 +0000 (13:02 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:24:57 +0000 (20:24 +0300)
Change-Id: I97b0f154cfd224b47f8266972bdfa488a0969e28
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
drivers/cpuidle/profiler.c
drivers/soc/samsung/exynos-cpupm.c
include/trace/events/ems.h
kernel/sched/ems/energy.c

index f9c4520a9e4e97fae1b3c25beb2d5b7d2ddcd954..afe320c8442201308c0aed8227eda9eb0e81071a 100644 (file)
@@ -482,7 +482,7 @@ cpuidle_profile_cpu_idle_register(struct cpuidle_driver *drv)
        }
 
        for (i = 0; i < state_count; i++)
-               strncpy(state[i].desc, drv->states[i].desc, DESC_LEN);
+               strncpy(state[i].desc, drv->states[i].desc, DESC_LEN - 1);
 
        cpu_idle_state = state;
        cpu_idle_state_count = state_count;
@@ -500,7 +500,7 @@ cpuidle_profile_group_idle_register(int id, const char *name)
        }
 
        state->id = id;
-       strncpy(state->desc, name, DESC_LEN);
+       strncpy(state->desc, name, DESC_LEN - 1);
 
        group_idle_state[group_idle_state_count] = state;
        group_idle_state_count++;
index 87ac5d7e9fa4cee9d8cb139a298706d08d6bef98..69d56dc274fcb862728f4cf10621d03f6c541403 100644 (file)
@@ -847,7 +847,7 @@ static int __init cpu_power_mode_init(void)
                }
 
                mode->id = id++;
-               strncpy(mode->name, dn->name, NAME_LEN);
+               strncpy(mode->name, dn->name, NAME_LEN - 1);
 
                of_property_read_u32(dn, "target-residency", &mode->target_residency);
                of_property_read_u32(dn, "psci-index", &mode->psci_index);
index 3d2e51edc6f26ae49d0f1a3417f9762c214b6211..0f425ff13cc72ddefbe121c643943d26047e5c41 100644 (file)
@@ -435,7 +435,7 @@ TRACE_EVENT(ems_manage_band,
                memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
                __entry->pid                    = p->pid;
                __entry->band_id                = band_id;
-               strncpy(__entry->event, event, 64);
+               strncpy(__entry->event, event, 63);
        ),
 
        TP_printk("comm=%s pid=%d band_id=%d event=%s",
index def7c302ec0f5d3b3acaed082533b6dbf592d097..bb0bf5bc53d4f0a181aecf73078fa920025ab6d1 100644 (file)
@@ -403,6 +403,10 @@ void init_sched_energy_table(struct cpumask *cpus, int table_size,
        unsigned long max_mips_freq = 0;
        int last_state;
 
+       cpumask_and(cpus, cpus, cpu_possible_mask);
+       if (cpumask_empty(cpus))
+               return;
+
        mips = per_cpu(energy_table, cpumask_any(cpus)).mips;
        for_each_cpu(cpu, cpus) {
                /*