mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 13:22:57 +00:00
selftests/resctrl: Don't leak buffer in fill_cache()
[ Upstream commit2d320b1029
] The error path in fill_cache() does return before the allocated buffer is freed leaking the buffer. The leak was introduced when fill_cache_read() started to return errors in commitc7b607fa93
("selftests/resctrl: Fix null pointer dereference on open failed"), before that both fill functions always returned 0. Move free() earlier to prevent the mem leak. Fixes:c7b607fa93
("selftests/resctrl: Fix null pointer dereference on open failed") Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
aabca80d93
commit
755fb5181f
1 changed files with 2 additions and 1 deletions
|
@ -177,12 +177,13 @@ fill_cache(unsigned long long buf_size, int malloc_and_init, int memflush,
|
|||
else
|
||||
ret = fill_cache_write(start_ptr, end_ptr, resctrl_val);
|
||||
|
||||
free(startptr);
|
||||
|
||||
if (ret) {
|
||||
printf("\n Error in fill cache read/write...\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(startptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue