mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] ovpn: use kmalloc_array() for array space allocation
@ 2025-09-01 11:21 chuguangqing
  2025-09-02  8:18 ` Simon Horman
  2025-09-02  9:00 ` PATCH v2 Re: " chuguangqing
  0 siblings, 2 replies; 9+ messages in thread
From: chuguangqing @ 2025-09-01 11:21 UTC (permalink / raw)
  To: Antonio Quartulli, Sabrina Dubroca, Andrew Lunn, davem,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, chuguangqing

Replace kmalloc(size * sizeof) with kmalloc_array() for safer memory
allocation and overflow prevention.

Signed-off-by: chuguangqing <chuguangqing@inspur.com>
---
 drivers/net/ovpn/crypto_aead.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ovpn/crypto_aead.c b/drivers/net/ovpn/crypto_aead.c
index 2cca759feffa..8274c3ae8d0b 100644
--- a/drivers/net/ovpn/crypto_aead.c
+++ b/drivers/net/ovpn/crypto_aead.c
@@ -72,8 +72,8 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
 		return -ENOSPC;
 
 	/* sg may be required by async crypto */
-	ovpn_skb_cb(skb)->sg = kmalloc(sizeof(*ovpn_skb_cb(skb)->sg) *
-				       (nfrags + 2), GFP_ATOMIC);
+	ovpn_skb_cb(skb)->sg = kmalloc_array((nfrags + 2), sizeof(*ovpn_skb_cb(skb)->sg),
+					     GFP_ATOMIC);
 	if (unlikely(!ovpn_skb_cb(skb)->sg))
 		return -ENOMEM;
 
@@ -185,8 +185,8 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct ovpn_crypto_key_slot *ks,
 		return -ENOSPC;
 
 	/* sg may be required by async crypto */
-	ovpn_skb_cb(skb)->sg = kmalloc(sizeof(*ovpn_skb_cb(skb)->sg) *
-				       (nfrags + 2), GFP_ATOMIC);
+	ovpn_skb_cb(skb)->sg = kmalloc_array((nfrags + 2), sizeof(*ovpn_skb_cb(skb)->sg),
+					     GFP_ATOMIC);
 	if (unlikely(!ovpn_skb_cb(skb)->sg))
 		return -ENOMEM;
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] ovpn: use kmalloc_array() for array space allocation
@ 2025-09-03 12:00 Gary Chu(楚光庆)
  0 siblings, 0 replies; 9+ messages in thread
From: Gary Chu(楚光庆) @ 2025-09-03 12:00 UTC (permalink / raw)
  To: Markus.Elfring, netdev
  Cc: linux-kernel, andrew+netdev, antonio, davem, edumazet, kuba,
	pabeni, sd, horms

[-- Attachment #1: Type: text/plain, Size: 804 bytes --]

Hi Markus,
	First of all, thank you for your reminder. According to your suggestion, the format "Chu Guangqing" should be used. However, in line with our company's signature conventions and my previous contributions to the kernel community, I have been using "chuguangqing". Therefore, I have to continue using this signature. The signature should not be changed frequently.

> 
> > Signed-off-by: chuguangqing <chuguangqing@inspur.com>
> 
> Would the personal name usually deviate a bit from the email identifier
> according to the Developer's Certificate of Origin?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docume
> ntation/process/submitting-patches.rst?h=v6.17-rc4#n436
> 
> Regards,
> Markus

Best regards,
Chu Guangqing
<chuguangqing@inspur.com>

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3931 bytes --]

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

end of thread, other threads:[~2025-09-03 12:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-01 11:21 [PATCH 1/1] ovpn: use kmalloc_array() for array space allocation chuguangqing
2025-09-02  8:18 ` Simon Horman
2025-09-02  9:00 ` PATCH v2 Re: " chuguangqing
2025-09-02  9:00   ` [PATCH v2 " chuguangqing
2025-09-02 13:15     ` Markus Elfring
2025-09-03 12:17       ` chuguangqing
2025-09-03 12:54         ` [v2] " Markus Elfring
2025-09-03  8:41     ` [PATCH v2 1/1] " Antonio Quartulli
2025-09-03 12:00 Gary Chu(楚光庆)

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

all inboxes | Powered by JetHome®