s5j/pwm: fix 32bit integer overflow when arithmetic operation
authorBongryul Lee <bongryul.lee@samsung.com>
Fri, 8 Sep 2017 13:43:15 +0000 (22:43 +0900)
committersunghan <sh924.chang@samsung.com>
Wed, 20 Sep 2017 08:42:37 +0000 (17:42 +0900)
Change-Id: I216557d33653bfbda9b46333847e9872b979992e
Signed-off-by: Bongryul Lee <bongryul.lee@samsung.com>
os/arch/arm/src/s5j/s5j_pwm.c

index 32145a4..db77e9c 100644 (file)
@@ -171,7 +171,7 @@ static int s5j_pwm_start(FAR struct pwm_lowerhalf_s *dev,
        FAR struct s5j_pwmtimer_s *priv = (FAR struct s5j_pwmtimer_s *)dev;
 
        tcntb = pwm_clk_freq(priv) / info->frequency - 1;
-       tcmpb = (((tcntb + 1) * info->duty) / 65536) - 1;
+       tcmpb = (((uint64_t)(tcntb + 1) * info->duty) / 65536) - 1;
 
        pwm_putreg32(priv, S5J_PWM_TCNTB_OFFSET(priv->id), tcntb);
        pwm_putreg32(priv, S5J_PWM_TCMPB_OFFSET(priv->id), tcmpb);