mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 22:26:55 +00:00
selftests/resctrl: Return NULL if malloc_and_init_memory() did not alloc mem
[ Upstream commit22a8be2803
] 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:a2561b12fe
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ae6803b663
commit
0bf90aac43
1 changed files with 2 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue