Skip to content

Commit

Permalink
selftests/resctrl: Return NULL if malloc_and_init_memory() did not al…
Browse files Browse the repository at this point in the history
…loc 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: a2561b1 ("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>
  • Loading branch information
Ilpo Järvinen authored and Shuah Khan committed Apr 10, 2023
1 parent 5290586 commit 22a8be2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/testing/selftests/resctrl/fill_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22a8be2

Please sign in to comment.