]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/resctrl: Don't leak buffer in fill_cache()
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 17 Jul 2023 13:14:50 +0000 (16:14 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:31 +0000 (12:22 +0200)
commitc68a196e7ff66f67f44663328358df1c0e6ca69a
treec11775704953c5da3b241a291b78fcbcc4019e5b
parentfdcb63afd3f6c8257f40b3362e2e617db5d95fee
selftests/resctrl: Don't leak buffer in fill_cache()

[ Upstream commit 2d320b1029ee7329ee0638181be967789775b962 ]

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 commit c7b607fa9325 ("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: c7b607fa9325 ("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>
tools/testing/selftests/resctrl/fill_buf.c