Skip to content

Commit 93b4041

Browse files
author
Hangbin Liu
committed
ptp: fix integer overflow in max_vclocks_store
JIRA: https://issues.redhat.com/browse/RHEL-85028 Upstream Status: net.git commit 81d23d2 commit 81d23d2 Author: Dan Carpenter <dan.carpenter@linaro.org> Date: Mon Jun 17 12:34:32 2024 +0300 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: 44c494c ("ptp: track available ptp vclocks information") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Heng Qi <hengqi@linux.alibaba.com> Link: https://lore.kernel.org/r/ee8110ed-6619-4bd7-9024-28c1f2ac24f4@moroto.mountain Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Hangbin Liu <haliu@redhat.com>
1 parent b2cc54a commit 93b4041

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/ptp/ptp_sysfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ static ssize_t max_vclocks_store(struct device *dev,
294294
if (max < ptp->n_vclocks)
295295
goto out;
296296

297-
size = sizeof(int) * max;
298-
vclock_index = kzalloc(size, GFP_KERNEL);
297+
vclock_index = kcalloc(max, sizeof(int), GFP_KERNEL);
299298
if (!vclock_index) {
300299
err = -ENOMEM;
301300
goto out;

0 commit comments

Comments
 (0)