Skip to content

Commit

Permalink
selftests/resctrl: Fix uninitialized .sa_flags
Browse files Browse the repository at this point in the history
commit beb7f47 upstream.

signal_handler_unregister() calls sigaction() with uninitializing
sa_flags in the struct sigaction.

Make sure sa_flags is always initialized in signal_handler_unregister()
by initializing the struct sigaction when declaring it. Also add the
initialization to signal_handler_register() even if there are no know
bugs in there because correctness is then obvious from the code itself.

Fixes: 73c55fa ("selftests/resctrl: Commonize the signal handler register/unregister for all tests")
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
ij-intel authored and gregkh committed Nov 28, 2023
1 parent 6f33bfa commit 23e60a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/resctrl/resctrl_val.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr)
*/
int signal_handler_register(void)
{
struct sigaction sigact;
struct sigaction sigact = {};
int ret = 0;

sigact.sa_sigaction = ctrlc_handler;
Expand All @@ -504,7 +504,7 @@ int signal_handler_register(void)
*/
void signal_handler_unregister(void)
{
struct sigaction sigact;
struct sigaction sigact = {};

sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
Expand Down

0 comments on commit 23e60a1

Please sign in to comment.