• Reinette Chatre's avatar
    x86/resctrl: Fix rdt_find_domain() return value and checks · 8edd32a1
    Reinette Chatre authored
    [ Upstream commit 52eb7433 ]
    
    rdt_find_domain() returns an ERR_PTR() that is generated from a provided
    domain id when the value is negative.
    
    Care needs to be taken when creating an ERR_PTR() from this value
    because a subsequent check using IS_ERR() expects the error to
    be within the MAX_ERRNO range. Using an invalid domain id as an
    ERR_PTR() does work at this time since this is currently always -1.
    Using this undocumented assumption is fragile since future users of
    rdt_find_domain() may not be aware of thus assumption.
    
    Two related issues are addressed:
    
    - Ensure that rdt_find_domain() always returns a valid error value by
    forcing the error to be -ENODEV when a negative domain id is provided.
    
    - 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: d89b7379 ("x86/intel_rdt/cqm: Add mon_data")
    Fixes: 521348b0 ("x86/intel_rdt: Introduce utility to obtain CDP peer")
    Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: fenghua.yu@intel.com
    Cc: gavin.hindman@intel.com
    Cc: jithu.joseph@intel.com
    Cc: x86-ml <x86@kernel.org>
    Link: https://lkml.kernel.org/r/b88cd4ff6a75995bf8db9b0ea546908fe50f69f3.1544479852.git.reinette.chatre@intel.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
    8edd32a1
Name
Last commit
Last update
..
alpha Loading commit data...
arc Loading commit data...
arm Loading commit data...
arm64 Loading commit data...
c6x Loading commit data...
csky Loading commit data...
h8300 Loading commit data...
hexagon Loading commit data...
ia64 Loading commit data...
m68k Loading commit data...
microblaze Loading commit data...
mips Loading commit data...
nds32 Loading commit data...
nios2 Loading commit data...
openrisc Loading commit data...
parisc Loading commit data...
powerpc Loading commit data...
riscv Loading commit data...
s390 Loading commit data...
sh Loading commit data...
sparc Loading commit data...
um Loading commit data...
unicore32 Loading commit data...
x86 Loading commit data...
xtensa Loading commit data...
.gitignore Loading commit data...
Kconfig Loading commit data...