]> git.itanic.dy.fi Git - linux-stable/commitdiff
selftests/resctrl: Fix uninitialized .sa_flags
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 2 Oct 2023 09:48:07 +0000 (12:48 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Oct 2023 20:54:04 +0000 (14:54 -0600)
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: 73c55fa5ab55 ("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>
tools/testing/selftests/resctrl/resctrl_val.c

index 51963a6f2186d406aa3714a324577ab51d209cf4..01bbe11a89834a66bb9410cbbe619273c50d8ef1 100644 (file)
@@ -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;
@@ -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);