netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 net-next] net: dsa: replace count*size kmalloc by kmalloc_array
@ 2014-11-14 18:36 Fabian Frederick
  2014-11-14 18:47 ` Joe Perches
  2014-11-16 19:43 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Fabian Frederick @ 2014-11-14 18:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Fabian Frederick, David S. Miller, netdev

kmalloc_array manages count*sizeof overflow.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 net/dsa/dsa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 4648f12..c00cca3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -526,7 +526,8 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
 
 	/* First time routing table allocation */
 	if (!cd->rtable) {
-		cd->rtable = kmalloc(pd->nr_chips * sizeof(s8), GFP_KERNEL);
+		cd->rtable = kmalloc_array(pd->nr_chips, sizeof(s8),
+					   GFP_KERNEL);
 		if (!cd->rtable)
 			return -ENOMEM;
 
-- 
1.9.3

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

end of thread, other threads:[~2014-11-16 19:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14 18:36 [PATCH 1/1 net-next] net: dsa: replace count*size kmalloc by kmalloc_array Fabian Frederick
2014-11-14 18:47 ` Joe Perches
2014-11-14 19:02   ` Fabian Frederick
2014-11-14 19:14     ` Joe Perches
2014-11-14 19:32       ` Fabian Frederick
2014-11-14 19:42         ` Joe Perches
2014-11-16 19:43 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).