diff options
author | Panagiotis Issaris <takis@issaris.org> | 2006-07-21 17:51:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-07-21 17:51:30 -0400 |
commit | 0da974f4f303a6842516b764507e3c0a03f41e5a (patch) | |
tree | 8872aec792f02040269c6769dd1009b20f71d186 /net/decnet | |
parent | a0ee7c70b22f78593957f99faa06acb4747b8bc0 (diff) |
[NET]: Conversions from kmalloc+memset to k(z|c)alloc.
Signed-off-by: Panagiotis Issaris <takis@issaris.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet')
-rw-r--r-- | net/decnet/dn_dev.c | 9 | ||||
-rw-r--r-- | net/decnet/dn_fib.c | 3 | ||||
-rw-r--r-- | net/decnet/dn_neigh.c | 3 | ||||
-rw-r--r-- | net/decnet/dn_rules.c | 3 | ||||
-rw-r--r-- | net/decnet/dn_table.c | 11 |
5 files changed, 8 insertions, 21 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c index 98a25208440d..476455fbdb03 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c | |||
@@ -413,11 +413,7 @@ static struct dn_ifaddr *dn_dev_alloc_ifa(void) | |||
413 | { | 413 | { |
414 | struct dn_ifaddr *ifa; | 414 | struct dn_ifaddr *ifa; |
415 | 415 | ||
416 | ifa = kmalloc(sizeof(*ifa), GFP_KERNEL); | 416 | ifa = kzalloc(sizeof(*ifa), GFP_KERNEL); |
417 | |||
418 | if (ifa) { | ||
419 | memset(ifa, 0, sizeof(*ifa)); | ||
420 | } | ||
421 | 417 | ||
422 | return ifa; | 418 | return ifa; |
423 | } | 419 | } |
@@ -1105,10 +1101,9 @@ struct dn_dev *dn_dev_create(struct net_device *dev, int *err) | |||
1105 | return NULL; | 1101 | return NULL; |
1106 | 1102 | ||
1107 | *err = -ENOBUFS; | 1103 | *err = -ENOBUFS; |
1108 | if ((dn_db = kmalloc(sizeof(struct dn_dev), GFP_ATOMIC)) == NULL) | 1104 | if ((dn_db = kzalloc(sizeof(struct dn_dev), GFP_ATOMIC)) == NULL) |
1109 | return NULL; | 1105 | return NULL; |
1110 | 1106 | ||
1111 | memset(dn_db, 0, sizeof(struct dn_dev)); | ||
1112 | memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms)); | 1107 | memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms)); |
1113 | smp_wmb(); | 1108 | smp_wmb(); |
1114 | dev->dn_ptr = dn_db; | 1109 | dev->dn_ptr = dn_db; |
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c index 0375077391b7..fa20e2efcfc1 100644 --- a/net/decnet/dn_fib.c +++ b/net/decnet/dn_fib.c | |||
@@ -283,11 +283,10 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta | |||
283 | goto err_inval; | 283 | goto err_inval; |
284 | } | 284 | } |
285 | 285 | ||
286 | fi = kmalloc(sizeof(*fi)+nhs*sizeof(struct dn_fib_nh), GFP_KERNEL); | 286 | fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct dn_fib_nh), GFP_KERNEL); |
287 | err = -ENOBUFS; | 287 | err = -ENOBUFS; |
288 | if (fi == NULL) | 288 | if (fi == NULL) |
289 | goto failure; | 289 | goto failure; |
290 | memset(fi, 0, sizeof(*fi)+nhs*sizeof(struct dn_fib_nh)); | ||
291 | 290 | ||
292 | fi->fib_protocol = r->rtm_protocol; | 291 | fi->fib_protocol = r->rtm_protocol; |
293 | fi->fib_nhs = nhs; | 292 | fi->fib_nhs = nhs; |
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index 5ce9c9e0565c..ff0ebe99137d 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c | |||
@@ -580,12 +580,11 @@ static int dn_neigh_seq_open(struct inode *inode, struct file *file) | |||
580 | { | 580 | { |
581 | struct seq_file *seq; | 581 | struct seq_file *seq; |
582 | int rc = -ENOMEM; | 582 | int rc = -ENOMEM; |
583 | struct neigh_seq_state *s = kmalloc(sizeof(*s), GFP_KERNEL); | 583 | struct neigh_seq_state *s = kzalloc(sizeof(*s), GFP_KERNEL); |
584 | 584 | ||
585 | if (!s) | 585 | if (!s) |
586 | goto out; | 586 | goto out; |
587 | 587 | ||
588 | memset(s, 0, sizeof(*s)); | ||
589 | rc = seq_open(file, &dn_neigh_seq_ops); | 588 | rc = seq_open(file, &dn_neigh_seq_ops); |
590 | if (rc) | 589 | if (rc) |
591 | goto out_kfree; | 590 | goto out_kfree; |
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c index 22f321d9bf9d..6986be754ef2 100644 --- a/net/decnet/dn_rules.c +++ b/net/decnet/dn_rules.c | |||
@@ -151,10 +151,9 @@ int dn_fib_rtm_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | new_r = kmalloc(sizeof(*new_r), GFP_KERNEL); | 154 | new_r = kzalloc(sizeof(*new_r), GFP_KERNEL); |
155 | if (!new_r) | 155 | if (!new_r) |
156 | return -ENOMEM; | 156 | return -ENOMEM; |
157 | memset(new_r, 0, sizeof(*new_r)); | ||
158 | 157 | ||
159 | if (rta[RTA_SRC-1]) | 158 | if (rta[RTA_SRC-1]) |
160 | memcpy(&new_r->r_src, RTA_DATA(rta[RTA_SRC-1]), 2); | 159 | memcpy(&new_r->r_src, RTA_DATA(rta[RTA_SRC-1]), 2); |
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c index 37d9d0a1ac8c..e926c952e363 100644 --- a/net/decnet/dn_table.c +++ b/net/decnet/dn_table.c | |||
@@ -158,12 +158,10 @@ static void dn_rehash_zone(struct dn_zone *dz) | |||
158 | break; | 158 | break; |
159 | } | 159 | } |
160 | 160 | ||
161 | ht = kmalloc(new_divisor*sizeof(struct dn_fib_node*), GFP_KERNEL); | 161 | ht = kcalloc(new_divisor, sizeof(struct dn_fib_node*), GFP_KERNEL); |
162 | |||
163 | if (ht == NULL) | 162 | if (ht == NULL) |
164 | return; | 163 | return; |
165 | 164 | ||
166 | memset(ht, 0, new_divisor*sizeof(struct dn_fib_node *)); | ||
167 | write_lock_bh(&dn_fib_tables_lock); | 165 | write_lock_bh(&dn_fib_tables_lock); |
168 | old_ht = dz->dz_hash; | 166 | old_ht = dz->dz_hash; |
169 | dz->dz_hash = ht; | 167 | dz->dz_hash = ht; |
@@ -184,11 +182,10 @@ static void dn_free_node(struct dn_fib_node *f) | |||
184 | static struct dn_zone *dn_new_zone(struct dn_hash *table, int z) | 182 | static struct dn_zone *dn_new_zone(struct dn_hash *table, int z) |
185 | { | 183 | { |
186 | int i; | 184 | int i; |
187 | struct dn_zone *dz = kmalloc(sizeof(struct dn_zone), GFP_KERNEL); | 185 | struct dn_zone *dz = kzalloc(sizeof(struct dn_zone), GFP_KERNEL); |
188 | if (!dz) | 186 | if (!dz) |
189 | return NULL; | 187 | return NULL; |
190 | 188 | ||
191 | memset(dz, 0, sizeof(struct dn_zone)); | ||
192 | if (z) { | 189 | if (z) { |
193 | dz->dz_divisor = 16; | 190 | dz->dz_divisor = 16; |
194 | dz->dz_hashmask = 0x0F; | 191 | dz->dz_hashmask = 0x0F; |
@@ -197,14 +194,12 @@ static struct dn_zone *dn_new_zone(struct dn_hash *table, int z) | |||
197 | dz->dz_hashmask = 0; | 194 | dz->dz_hashmask = 0; |
198 | } | 195 | } |
199 | 196 | ||
200 | dz->dz_hash = kmalloc(dz->dz_divisor*sizeof(struct dn_fib_node *), GFP_KERNEL); | 197 | dz->dz_hash = kcalloc(dz->dz_divisor, sizeof(struct dn_fib_node *), GFP_KERNEL); |
201 | |||
202 | if (!dz->dz_hash) { | 198 | if (!dz->dz_hash) { |
203 | kfree(dz); | 199 | kfree(dz); |
204 | return NULL; | 200 | return NULL; |
205 | } | 201 | } |
206 | 202 | ||
207 | memset(dz->dz_hash, 0, dz->dz_divisor*sizeof(struct dn_fib_node*)); | ||
208 | dz->dz_order = z; | 203 | dz->dz_order = z; |
209 | dz->dz_mask = dnet_make_mask(z); | 204 | dz->dz_mask = dnet_make_mask(z); |
210 | 205 | ||