Re: [PATCH v2] hw/misc: Fix arith overflow in NPCM7XX PWM module

2021-01-28 Thread Peter Maydell
On Wed, 27 Jan 2021 at 01:11, Hao Wu 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_MA

[PATCH v2] hw/misc: Fix arith overflow in NPCM7XX PWM module

2021-01-26 Thread wuhaotsh--- via
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 conv