[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] hw/misc: Fix arith overflow in NPCM7XX PWM module
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2] hw/misc: Fix arith overflow in NPCM7XX PWM module |
Date: |
Thu, 28 Jan 2021 12:11:38 +0000 |
On Wed, 27 Jan 2021 at 01:11, Hao Wu <wuhaotsh@google.com> wrote:
>
> Fix potential overflow problem when calculating pwm_duty.
> 1. Ensure p->cmr and p->cnr to be from [0,65535], according to the
> hardware specification.
> 2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1)
> can excceed UINT32_MAX, we convert them to uint64_t in computation
> and converted them back to uint32_t.
> (duty is guaranteed to be <= MAX_DUTY so it won't overflow.)
>
> Fixes: CID 1442342
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Reviewed-by: Doug Evans <dje@google.com>
> Signed-off-by: Hao Wu <wuhaotsh@google.com>
> ---
Applied to target-arm.next, thanks.
-- PMM