cpu: fix prevent defect
authorPark Bumgyu <bumgyu.park@samsung.com>
Tue, 24 Jul 2018 04:02:35 +0000 (13:02 +0900)
committerhskang <hs1218.kang@samsung.com>
Wed, 10 Oct 2018 07:23:13 +0000 (16:23 +0900)
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 580d2ed42fc0e5ddc7fa899c0626a4c0c8ed90fc..c4725a53c126c34c143e0e9ad91c6def4e392e86 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 dc456e9f5d6bd0fb7780f154ba74d99d9b52181f..5666aa1bdd442b2468aee8f58d851e73a433f8aa 100644 (file)
@@ -842,7 +842,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 d5f7529a8d0817bd63c6d03e9342099375c32ecc..db0723fb607aa0a0e86ac0ae0031379b84422d0b 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 7acd9adc210e77893222695eebeefc8c91d53864..a609b611bdf10e1f8b7de9abd3dc4f3fbd8741f8 100644 (file)
@@ -399,6 +399,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) {
                /*