Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7aa39dc8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "sched: energy: handle memory allocation failure"

parents 6abc9370 75f53af2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -84,11 +84,17 @@ void init_sched_energy_costs(void)

			sge = kcalloc(1, sizeof(struct sched_group_energy),
				      GFP_NOWAIT);
			if (!sge)
				goto out;

			nstates = (prop->length / sizeof(u32)) / 2;
			cap_states = kcalloc(nstates,
					     sizeof(struct capacity_state),
					     GFP_NOWAIT);
			if (!cap_states) {
				kfree(sge);
				goto out;
			}

			for (i = 0, val = prop->value; i < nstates; i++) {
				cap_states[i].cap = be32_to_cpup(val++);
@@ -101,6 +107,8 @@ void init_sched_energy_costs(void)
			prop = of_find_property(cp, "idle-cost-data", NULL);
			if (!prop || !prop->value) {
				pr_warn("No idle-cost data, skipping sched_energy init\n");
				kfree(sge);
				kfree(cap_states);
				goto out;
			}

@@ -108,6 +116,11 @@ void init_sched_energy_costs(void)
			idle_states = kcalloc(nstates,
					      sizeof(struct idle_state),
					      GFP_NOWAIT);
			if (!idle_states) {
				kfree(sge);
				kfree(cap_states);
				goto out;
			}

			for (i = 0, val = prop->value; i < nstates; i++)
				idle_states[i].power = be32_to_cpup(val++);