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

Commit 01e00127 authored by Amir Vajid's avatar Amir Vajid
Browse files

PM / devfreq: memlat: add missing alloc check in start_hwmon



Add a check in start_hwmon() to confirm alloc_attr() was able
to allocate memory and return -ENOMEM on failure.

Change-Id: I8cadaacc70ad13d60b6225b0d04e11e5b9aa9e5e
Signed-off-by: default avatarAmir Vajid <avajid@codeaurora.org>
parent 25064a00
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -338,11 +338,14 @@ static void memlat_monitor_work(struct work_struct *work)
static int start_hwmon(struct memlat_hwmon *hw)
{
	int ret = 0;
	struct perf_event_attr *attr = alloc_attr();
	unsigned int cpu;
	struct memlat_mon *mon = to_mon(hw);
	struct memlat_cpu_grp *cpu_grp = mon->cpu_grp;
	bool should_init_cpu_grp;
	struct perf_event_attr *attr = alloc_attr();

	if (!attr)
		return -ENOMEM;

	mutex_lock(&cpu_grp->mons_lock);
	should_init_cpu_grp = !(cpu_grp->num_active_mons++);