diff options
| author | Dan Carpenter <dan.carpenter@linaro.org> | 2024-06-17 12:34:32 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-06-27 13:49:07 +0200 |
| commit | 666e934d749e50a37f3796caaf843a605f115b6f (patch) | |
| tree | 03269364b2f4247e28594bea5f7e38c5393b3c7e /drivers/ptp | |
| parent | 9126fd82e9edc7b4796f756e4b258d34f17e5e4a (diff) | |
| download | linux-666e934d749e50a37f3796caaf843a605f115b6f.tar.gz linux-666e934d749e50a37f3796caaf843a605f115b6f.tar.bz2 linux-666e934d749e50a37f3796caaf843a605f115b6f.zip | |
ptp: fix integer overflow in max_vclocks_store
[ Upstream commit 81d23d2a24012e448f651e007fac2cfd20a45ce0 ]
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 <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: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/ptp')
| -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 34ea5c16123a..aefc06ae5d09 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -294,8 +294,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; |
