Hao Wu
1e5ce6e10a
hw/misc: Fix arith overflow in NPCM7XX PWM module
...
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>
Message-id: 20210127011142.2122790-1-wuhaotsh@google.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2021-01-29 10:47:28 +00:00
..
2021-01-23 15:55:07 -05:00
2021-01-17 06:42:54 -05:00
2020-09-14 14:23:19 +01:00
2021-01-26 18:38:37 +01:00
2020-12-18 09:14:23 +01:00
2021-01-18 10:04:31 +00:00
2020-10-17 10:45:50 -04:00
2020-11-17 09:45:24 +01:00
2021-01-20 10:46:54 +01:00
2020-10-13 12:48:17 +02:00
2020-10-09 17:27:55 +01:00
2020-10-17 10:45:52 -04:00
2021-01-27 20:53:14 +01:00
2021-01-29 10:47:28 +00:00
2021-01-21 11:19:45 +01:00
2020-10-13 12:48:17 +02:00
2020-11-25 12:50:48 -05:00
2020-09-23 16:07:44 +01:00
2020-09-23 16:07:44 +01:00
2020-09-10 11:02:17 +01:00
2020-09-10 11:02:17 +01:00
2020-09-10 11:02:17 +01:00
2021-01-27 20:53:14 +01:00
2020-12-19 10:39:16 +01:00
2020-12-19 10:37:16 +01:00
2020-12-19 10:39:41 +01:00
2020-09-09 09:27:09 -04:00
2020-09-18 13:49:48 -04:00
2020-12-19 10:39:41 +01:00
2020-11-15 17:04:40 +01:00
2020-11-15 17:04:40 +01:00
2020-09-23 16:07:44 +01:00
2020-10-17 10:45:51 -04:00
2021-01-12 12:38:03 +01:00
2020-10-22 11:53:54 -04:00
2020-09-23 16:07:44 +01:00
2020-09-23 16:07:44 +01:00
2020-12-18 12:25:42 +01:00
2020-09-16 08:41:06 +02:00
2020-09-23 16:07:44 +01:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-11-15 17:04:40 +01:00
2020-10-27 15:26:20 +01:00
2020-10-13 13:33:46 +02:00
2020-11-15 17:04:40 +01:00
2021-01-13 10:21:17 +01:00
2020-12-19 10:20:14 +01:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-11-15 17:04:40 +01:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-09-23 13:45:52 +01:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-10-29 09:57:37 +00:00
2020-09-23 13:41:58 +01:00
2020-10-15 16:06:27 +02:00
2020-09-23 16:07:44 +01:00
2020-09-16 12:15:07 +02:00
2021-01-23 15:55:08 -05:00
2020-12-09 08:04:34 +01:00
2020-11-15 17:04:40 +01:00
2020-10-09 07:08:19 +02:00
2020-09-03 09:38:36 +02:00
2021-01-28 08:08:45 +01:00
2020-09-23 16:07:44 +01:00
2020-09-16 08:41:06 +02:00
2021-01-28 08:08:45 +01:00
2020-09-23 16:07:44 +01:00
2020-10-05 16:41:22 +02:00
2020-09-07 12:34:17 +02:00
2020-11-03 13:17:25 +00:00
2020-11-15 17:04:40 +01:00
2020-12-19 10:38:43 +01:00
2020-09-16 08:41:06 +02:00
2020-12-11 17:52:40 +01:00
2020-09-02 07:29:26 -04:00
2021-01-20 10:46:54 +01:00
2020-12-08 13:48:58 -05:00