[2/4] arch: um: avoid using uninitialized regs
diff mbox series

Message ID 20190823104429.11047-2-johannes@sipsolutions.net
State Accepted
Headers show
Series
  • [1/4] arch: um: remove sig_info[SIGALRM]
Related show

Commit Message

Johannes Berg Aug. 23, 2019, 10:44 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

In timer_real_alarm_handler(), regs is only initialized if
the context argument is non-NULL, also initialize in the
other case.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 arch/um/os-Linux/signal.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Anton Ivanov Aug. 27, 2019, 5:28 a.m. UTC | #1
On 23/08/2019 11:44, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> In timer_real_alarm_handler(), regs is only initialized if
> the context argument is non-NULL, also initialize in the
> other case.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   arch/um/os-Linux/signal.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
> index 35d1b2bc00cb..4cd88b5b9006 100644
> --- a/arch/um/os-Linux/signal.c
> +++ b/arch/um/os-Linux/signal.c
> @@ -10,6 +10,7 @@
>   #include <stdarg.h>
>   #include <errno.h>
>   #include <signal.h>
> +#include <string.h>
>   #include <strings.h>
>   #include <as-layout.h>
>   #include <kern_util.h>
> @@ -88,6 +89,8 @@ static void timer_real_alarm_handler(mcontext_t *mc)
>   
>   	if (mc != NULL)
>   		get_regs_from_mc(&regs, mc);
> +	else
> +		memset(&regs, 0, sizeof(regs));
>   	timer_handler(SIGALRM, NULL, &regs);
>   }
>   
> 

Acked-by: Anton Ivanov <anton.ivanov@cambridgegreys.co.uk>

Patch
diff mbox series

diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 35d1b2bc00cb..4cd88b5b9006 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -10,6 +10,7 @@ 
 #include <stdarg.h>
 #include <errno.h>
 #include <signal.h>
+#include <string.h>
 #include <strings.h>
 #include <as-layout.h>
 #include <kern_util.h>
@@ -88,6 +89,8 @@  static void timer_real_alarm_handler(mcontext_t *mc)
 
 	if (mc != NULL)
 		get_regs_from_mc(&regs, mc);
+	else
+		memset(&regs, 0, sizeof(regs));
 	timer_handler(SIGALRM, NULL, &regs);
 }