linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks
@ 2018-11-28 18:20 Reinette Chatre
  2018-12-10 19:13 ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Reinette Chatre @ 2018-11-28 18:20 UTC (permalink / raw)
  To: tglx, fenghua.yu, bp, tony.luck
  Cc: jithu.joseph, mingo, hpa, x86, linux-kernel, Reinette Chatre

rdt_find_domain() may return an ERR_PTR(), NULL, or a pointer to struct
rdt_domain. It is thus required that the return value be checked for the
possibility of an ERR_PTR as well as NULL.

In a few instances the return value of rdt_find_domain() is just checked
for NULL - fix these to include a check of ERR_PTR.

Fixes: d89b7379015f ("x86/intel_rdt/cqm: Add mon_data")
Fixes: 521348b011d6 ("x86/intel_rdt: Introduce utility to obtain CDP peer")
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
Dear Maintainers,

Two original commits are fixed here. d89b7379015f can be found in v4.14 and
521348b011d6 starting in v4.20. I am unsure whether this is appropriate for
stable since it is not fixing an issue reported by users. This issue was
discovered during code inspection.

Thank you

Reinette


 arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +-
 arch/x86/kernel/cpu/resctrl/rdtgroup.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 6f7adb3be01e..3b5de7d54307 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -538,7 +538,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
 
 	r = &rdt_resources_all[resid];
 	d = rdt_find_domain(r, domid, NULL);
-	if (!d) {
+	if (IS_ERR_OR_NULL(d)) {
 		ret = -ENOENT;
 		goto out;
 	}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 1c7827d142e7..715c6697b07d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1029,7 +1029,7 @@ static int rdt_cdp_peer_get(struct rdt_resource *r, struct rdt_domain *d,
 	 * peer RDT CDP resource. Hence the WARN.
 	 */
 	_d_cdp = rdt_find_domain(_r_cdp, d->id, NULL);
-	if (WARN_ON(!_d_cdp)) {
+	if (WARN_ON(IS_ERR_OR_NULL(_d_cdp))) {
 		_r_cdp = NULL;
 		ret = -EINVAL;
 	}
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-10 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28 18:20 [PATCH] x86/resctrl: Fix rdt_find_domain() return value checks Reinette Chatre
2018-12-10 19:13 ` Borislav Petkov
2018-12-10 20:42   ` Reinette Chatre
2018-12-10 21:04     ` Borislav Petkov
2018-12-10 21:42       ` Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).