Commit 9d83068b authored by James Morse's avatar James Morse Committed by Wenkuan Wang
Browse files

x86/resctrl: Fix kfree() of the wrong type in domain_add_cpu()

mainline inclusion
from mainline-v5.15-rc5
commit d4ebfca2
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9U2JC


CVE: NA

--------------------------------

Commit in Fixes separated the architecture specific and filesystem parts
of the resctrl domain structures.

This left the error paths in domain_add_cpu() kfree()ing the memory with
the wrong type.

This will cause a problem if someone adds a new member to struct
rdt_hw_domain meaning d_resctrl is no longer the first member.

Fixes: 792e0f6f ("x86/resctrl: Split struct rdt_domain")
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Acked-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Link: https://lkml.kernel.org/r/20210917165924.28254-1-james.morse@arm.com



Conflicts:
	arch/x86/kernel/cpu/resctrl/core.c

Signed-off-by: default avatarWenkuan Wang <Wenkuan.Wang@amd.com>
parent 0a0d6ecf
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -642,14 +642,14 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
	rdt_domain_reconfigure_cdp(r);

	if (r->alloc_capable && domain_setup_ctrlval(r, d)) {
		kfree(d);
		kfree(hw_dom);
		return;
	}

	if (r->mon_capable && domain_setup_mon_state(r, d)) {
		kfree(d->ctrl_val);
		kfree(d->mbps_val);
		kfree(d);
		kfree(hw_dom->ctrl_val);
		kfree(hw_dom->mbps_val);
		kfree(hw_dom);
		return;
	}