Commit 81d23d2a authored by Dan Carpenter's avatar Dan Carpenter Committed by Jakub Kicinski

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: 44c494c8 ("ptp: track available ptp vclocks information")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarHeng Qi <hengqi@linux.alibaba.com>
Link: https://lore.kernel.org/r/ee8110ed-6619-4bd7-9024-28c1f2ac24f4@moroto.mountainSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 88c67aeb
...@@ -296,8 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev, ...@@ -296,8 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev,
if (max < ptp->n_vclocks) if (max < ptp->n_vclocks)
goto out; goto out;
size = sizeof(int) * max; vclock_index = kcalloc(max, sizeof(int), GFP_KERNEL);
vclock_index = kzalloc(size, GFP_KERNEL);
if (!vclock_index) { if (!vclock_index) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment