lkml.org 
[lkml]   [2019]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] time: fix a assignment error in ntp module
On Mon, 22 Apr 2019, Weikang shi wrote:
> From: swkhack <swkhack@gmail.com>
>
> It is meanless to check a 64bit(txc->constant) value is postive
> when the value has to be assigned to a 32 bit variable(*time_tai).
> So I make a temp type conversion before the compare.

Errm no. This is missing a proper range check in the first place.

> Signed-off-by: swkhack <swkhack@gmail.com>
> ---
> kernel/time/ntp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
> index 92a90014a..6b454eafc 100644
> --- a/kernel/time/ntp.c
> +++ b/kernel/time/ntp.c
> @@ -690,7 +690,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc,
> time_constant = max(time_constant, 0l);
> }
>
> - if (txc->modes & ADJ_TAI && txc->constant > 0)
> + if (txc->modes & ADJ_TAI && (int)txc->constant > 0)
> *time_tai = txc->constant;
>
> if (txc->modes & ADJ_OFFSET)
> --
> 2.17.1
>
>

\
 
 \ /
  Last update: 2019-04-24 22:23    [W:0.351 / U:1.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site