Netdev List
 help / color / mirror / Atom feed
* [PATCH net] ptp: fix integer overflow in max_vclocks_store
@ 2024-06-14 17:31 Dan Carpenter
  2024-06-15  7:05 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-06-14 17:31 UTC (permalink / raw)
  To: Yangbo Lu
  Cc: Richard Cochran, David S. Miller, netdev, linux-kernel,
	kernel-janitors

On 32bit systems, the "4 * max" multiply can overflow.  Use size_mul()
to fix this.

Fixes: 44c494c8e30e ("ptp: track available ptp vclocks information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/ptp/ptp_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index a15460aaa03b..bc1562fcd6c9 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -296,7 +296,7 @@ static ssize_t max_vclocks_store(struct device *dev,
 	if (max < ptp->n_vclocks)
 		goto out;
 
-	size = sizeof(int) * max;
+	size = size_mul(sizeof(int), max);
 	vclock_index = kzalloc(size, GFP_KERNEL);
 	if (!vclock_index) {
 		err = -ENOMEM;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-17  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-14 17:31 [PATCH net] ptp: fix integer overflow in max_vclocks_store Dan Carpenter
2024-06-15  7:05 ` Christophe JAILLET
2024-06-17  6:01   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox