Skip to content

Commit 81d23d2

Browse files
Dan Carpenterkuba-moo
authored andcommitted
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 <[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]>
1 parent 88c67ae commit 81d23d2

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
@@ -296,8 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev,
296296
if (max < ptp->n_vclocks)
297297
goto out;
298298

299-
size = sizeof(int) * max;
300-
vclock_index = kzalloc(size, GFP_KERNEL);
299+
vclock_index = kcalloc(max, sizeof(int), GFP_KERNEL);
301300
if (!vclock_index) {
302301
err = -ENOMEM;
303302
goto out;

0 commit comments

Comments
 (0)