mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kzalloc: use in alloc_netdev
@ 2006-04-07  5:32 Paolo 'Blaisorblade' Giarrusso
  2006-04-07  5:38 ` David S. Miller
  2006-04-07  5:52 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2006-04-07  5:32 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Noticed this use, fixed it.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 net/core/dev.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 434220d..dfb6299 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3100,12 +3100,11 @@ struct net_device *alloc_netdev(int size
 	alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
 	alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
 
-	p = kmalloc(alloc_size, GFP_KERNEL);
+	p = kzalloc(alloc_size, GFP_KERNEL);
 	if (!p) {
 		printk(KERN_ERR "alloc_dev: Unable to allocate device.\n");
 		return NULL;
 	}
-	memset(p, 0, alloc_size);
 
 	dev = (struct net_device *)
 		(((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);

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

* Re: [PATCH] kzalloc: use in alloc_netdev
  2006-04-07  5:32 [PATCH] kzalloc: use in alloc_netdev Paolo 'Blaisorblade' Giarrusso
@ 2006-04-07  5:38 ` David S. Miller
  2006-04-07  5:52 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: David S. Miller @ 2006-04-07  5:38 UTC (permalink / raw)
  To: blaisorblade; +Cc: akpm, linux-kernel

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Date: Fri, 07 Apr 2006 07:32:05 +0200

> From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> 
> Noticed this use, fixed it.
> 
> Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Applied, thanks.

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

* Re: [PATCH] kzalloc: use in alloc_netdev
  2006-04-07  5:32 [PATCH] kzalloc: use in alloc_netdev Paolo 'Blaisorblade' Giarrusso
  2006-04-07  5:38 ` David S. Miller
@ 2006-04-07  5:52 ` Andrew Morton
  2006-04-07 21:53   ` David S. Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-04-07  5:52 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso; +Cc: linux-kernel

"Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it> wrote:
>
> Noticed this use, fixed it.

OK, but I think that if we're going to make conversions like this it's best
to do it in decent-sized chunks, just to keep the patch volume down.

umm,

 net/core/dev.c           |    3 +--
 net/core/dv.c            |    5 +----
 net/core/flow.c          |    4 +---
 net/core/gen_estimator.c |    3 +--
 net/core/neighbour.c     |   14 ++++----------
 net/core/request_sock.c  |    4 +---
 6 files changed, 9 insertions(+), 24 deletions(-)

diff -puN net/core/dev.c~net-kzalloc-conversion net/core/dev.c
--- devel/net/core/dev.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/dev.c	2006-04-06 22:50:24.000000000 -0700
@@ -3100,12 +3100,11 @@ struct net_device *alloc_netdev(int size
 	alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST;
 	alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
 
-	p = kmalloc(alloc_size, GFP_KERNEL);
+	p = kzalloc(alloc_size, GFP_KERNEL);
 	if (!p) {
 		printk(KERN_ERR "alloc_dev: Unable to allocate device.\n");
 		return NULL;
 	}
-	memset(p, 0, alloc_size);
 
 	dev = (struct net_device *)
 		(((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
diff -puN net/core/dv.c~net-kzalloc-conversion net/core/dv.c
--- devel/net/core/dv.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/dv.c	2006-04-06 22:50:24.000000000 -0700
@@ -55,15 +55,12 @@ int alloc_divert_blk(struct net_device *
 
 	dev->divert = NULL;
 	if (dev->type == ARPHRD_ETHER) {
-		dev->divert = (struct divert_blk *)
-			kmalloc(alloc_size, GFP_KERNEL);
+		dev->divert = kzalloc(alloc_size, GFP_KERNEL);
 		if (dev->divert == NULL) {
 			printk(KERN_INFO "divert: unable to allocate divert_blk for %s\n",
 			       dev->name);
 			return -ENOMEM;
 		}
-
-		memset(dev->divert, 0, sizeof(struct divert_blk));
 		dev_hold(dev);
 	}
 
diff -puN net/core/flow.c~net-kzalloc-conversion net/core/flow.c
--- devel/net/core/flow.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/flow.c	2006-04-06 22:50:24.000000000 -0700
@@ -318,12 +318,10 @@ static void __devinit flow_cache_cpu_pre
 		/* NOTHING */;
 
 	flow_table(cpu) = (struct flow_cache_entry **)
-		__get_free_pages(GFP_KERNEL, order);
+		__get_free_pages(GFP_KERNEL|__GFP_ZERO, order);
 	if (!flow_table(cpu))
 		panic("NET: failed to allocate flow cache order %lu\n", order);
 
-	memset(flow_table(cpu), 0, PAGE_SIZE << order);
-
 	flow_hash_rnd_recalc(cpu) = 1;
 	flow_count(cpu) = 0;
 
diff -puN net/core/gen_estimator.c~net-kzalloc-conversion net/core/gen_estimator.c
--- devel/net/core/gen_estimator.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/gen_estimator.c	2006-04-06 22:50:24.000000000 -0700
@@ -159,11 +159,10 @@ int gen_new_estimator(struct gnet_stats_
 	if (parm->interval < -2 || parm->interval > 3)
 		return -EINVAL;
 
-	est = kmalloc(sizeof(*est), GFP_KERNEL);
+	est = kzalloc(sizeof(*est), GFP_KERNEL);
 	if (est == NULL)
 		return -ENOBUFS;
 
-	memset(est, 0, sizeof(*est));
 	est->interval = parm->interval + 2;
 	est->bstats = bstats;
 	est->rate_est = rate_est;
diff -puN net/core/neighbour.c~net-kzalloc-conversion net/core/neighbour.c
--- devel/net/core/neighbour.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/neighbour.c	2006-04-06 22:50:24.000000000 -0700
@@ -284,14 +284,11 @@ static struct neighbour **neigh_hash_all
 	struct neighbour **ret;
 
 	if (size <= PAGE_SIZE) {
-		ret = kmalloc(size, GFP_ATOMIC);
+		ret = kzalloc(size, GFP_ATOMIC);
 	} else {
 		ret = (struct neighbour **)
-			__get_free_pages(GFP_ATOMIC, get_order(size));
+		      __get_free_pages(GFP_ATOMIC|__GFP_ZERO, get_order(size));
 	}
-	if (ret)
-		memset(ret, 0, size);
-
 	return ret;
 }
 
@@ -1089,8 +1086,7 @@ static void neigh_hh_init(struct neighbo
 		if (hh->hh_type == protocol)
 			break;
 
-	if (!hh && (hh = kmalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
-		memset(hh, 0, sizeof(struct hh_cache));
+	if (!hh && (hh = kzalloc(sizeof(*hh), GFP_ATOMIC)) != NULL) {
 		rwlock_init(&hh->hh_lock);
 		hh->hh_type = protocol;
 		atomic_set(&hh->hh_refcnt, 0);
@@ -1366,13 +1362,11 @@ void neigh_table_init(struct neigh_table
 	tbl->hash_buckets = neigh_hash_alloc(tbl->hash_mask + 1);
 
 	phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *);
-	tbl->phash_buckets = kmalloc(phsize, GFP_KERNEL);
+	tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL);
 
 	if (!tbl->hash_buckets || !tbl->phash_buckets)
 		panic("cannot allocate neighbour cache hashes");
 
-	memset(tbl->phash_buckets, 0, phsize);
-
 	get_random_bytes(&tbl->hash_rnd, sizeof(tbl->hash_rnd));
 
 	rwlock_init(&tbl->lock);
diff -puN net/core/request_sock.c~net-kzalloc-conversion net/core/request_sock.c
--- devel/net/core/request_sock.c~net-kzalloc-conversion	2006-04-06 22:50:24.000000000 -0700
+++ devel-akpm/net/core/request_sock.c	2006-04-06 22:50:24.000000000 -0700
@@ -38,13 +38,11 @@ int reqsk_queue_alloc(struct request_soc
 {
 	const int lopt_size = sizeof(struct listen_sock) +
 			      nr_table_entries * sizeof(struct request_sock *);
-	struct listen_sock *lopt = kmalloc(lopt_size, GFP_KERNEL);
+	struct listen_sock *lopt = kzalloc(lopt_size, GFP_KERNEL);
 
 	if (lopt == NULL)
 		return -ENOMEM;
 
-	memset(lopt, 0, lopt_size);
-
 	for (lopt->max_qlen_log = 6;
 	     (1 << lopt->max_qlen_log) < sysctl_max_syn_backlog;
 	     lopt->max_qlen_log++);
_


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

* Re: [PATCH] kzalloc: use in alloc_netdev
  2006-04-07  5:52 ` Andrew Morton
@ 2006-04-07 21:53   ` David S. Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David S. Miller @ 2006-04-07 21:53 UTC (permalink / raw)
  To: akpm; +Cc: blaisorblade, linux-kernel

From: Andrew Morton <akpm@osdl.org>
Date: Thu, 6 Apr 2006 22:52:32 -0700

> "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it> wrote:
> >
> > Noticed this use, fixed it.
> 
> OK, but I think that if we're going to make conversions like this it's best
> to do it in decent-sized chunks, just to keep the patch volume down.

Applied, thanks.

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

end of thread, other threads:[~2006-04-07 21:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-07  5:32 [PATCH] kzalloc: use in alloc_netdev Paolo 'Blaisorblade' Giarrusso
2006-04-07  5:38 ` David S. Miller
2006-04-07  5:52 ` Andrew Morton
2006-04-07 21:53   ` David S. Miller

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®