diff options
author | Dan Carpenter <[email protected]> | 2024-06-17 12:34:32 +0300 |
---|---|---|
committer | Jakub Kicinski <[email protected]> | 2024-06-18 13:26:44 -0700 |
commit | 81d23d2a24012e448f651e007fac2cfd20a45ce0 (patch) | |
tree | 025f2646e1d0785f4be33cce130db5f4ba08378d | |
parent | 88c67aeb14070bab61d3dd8be96c8b42ebcaf53a (diff) |
ptp: fix integer overflow in max_vclocks_store
On 32bit systems, the "4 * max" multiply can overflow. Use kcalloc()
to do the allocation to prevent this.
Fixes: 44c494c8e30e ("ptp: track available ptp vclocks information")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Wojciech Drewek <[email protected]>
Reviewed-by: Jiri Pirko <[email protected]>
Reviewed-by: Heng Qi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
-rw-r--r-- | drivers/ptp/ptp_sysfs.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index a15460aaa03b..6b1b8f57cd95 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -296,8 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev, if (max < ptp->n_vclocks) goto out; - size = sizeof(int) * max; - vclock_index = kzalloc(size, GFP_KERNEL); + vclock_index = kcalloc(max, sizeof(int), GFP_KERNEL); if (!vclock_index) { err = -ENOMEM; goto out; |