summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/resctrl
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2023-02-15 16:05:57 +0300
committerShuah Khan <skhan@linuxfoundation.org>2023-04-10 21:20:28 +0300
commit22a8be280383812235131dda18a8212a59fadd2d (patch)
tree3330ced3cd2e3fdfdf7cba1cefc40fff694699ff /tools/testing/selftests/resctrl
parent5290586186d24d81d7f8eee4ba837f0cbc304b09 (diff)
downloadlinux-22a8be280383812235131dda18a8212a59fadd2d.tar.xz
selftests/resctrl: Return NULL if malloc_and_init_memory() did not alloc mem
malloc_and_init_memory() in fill_buf isn't checking if memalign() successfully allocated memory or not before accessing the memory. Check the return value of memalign() and return NULL if allocating aligned memory fails. Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark") Co-developed-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl')
-rw-r--r--tools/testing/selftests/resctrl/fill_buf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c
index 56ccbeae0638..c20d0a7ecbe6 100644
--- a/tools/testing/selftests/resctrl/fill_buf.c
+++ b/tools/testing/selftests/resctrl/fill_buf.c
@@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s)
size_t s64;
void *p = memalign(PAGE_SIZE, s);
+ if (!p)
+ return NULL;
p64 = (uint64_t *)p;
s64 = s / sizeof(uint64_t);