diff options
author | Yoann Padioleau <padator@wanadoo.fr> | 2007-07-19 04:49:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:50 -0400 |
commit | dd00cc486ab1c17049a535413d1751ef3482141c (patch) | |
tree | d90ff69ea06792b9284f2f2665c96624f121b88a /drivers/net | |
parent | 3b5ad0797c0e4049001f961a8b58f1d0ce532072 (diff) |
some kmalloc/memset ->kzalloc (tree wide)
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing
this transformation:
@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@
x =
- kmalloc
+ kzalloc
(E1,E2)
... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);
@@
expression E1,E2,E3;
@@
- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)
[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/net')
30 files changed, 35 insertions, 73 deletions
diff --git a/drivers/net/b44.c b/drivers/net/b44.c index 96fb0ec905a7..37f1b6ff5c12 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c | |||
@@ -1519,14 +1519,13 @@ static void b44_setup_pseudo_magicp(struct b44 *bp) | |||
1519 | u8 *pwol_pattern; | 1519 | u8 *pwol_pattern; |
1520 | u8 pwol_mask[B44_PMASK_SIZE]; | 1520 | u8 pwol_mask[B44_PMASK_SIZE]; |
1521 | 1521 | ||
1522 | pwol_pattern = kmalloc(B44_PATTERN_SIZE, GFP_KERNEL); | 1522 | pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL); |
1523 | if (!pwol_pattern) { | 1523 | if (!pwol_pattern) { |
1524 | printk(KERN_ERR PFX "Memory not available for WOL\n"); | 1524 | printk(KERN_ERR PFX "Memory not available for WOL\n"); |
1525 | return; | 1525 | return; |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | /* Ipv4 magic packet pattern - pattern 0.*/ | 1528 | /* Ipv4 magic packet pattern - pattern 0.*/ |
1529 | memset(pwol_pattern, 0, B44_PATTERN_SIZE); | ||
1530 | memset(pwol_mask, 0, B44_PMASK_SIZE); | 1529 | memset(pwol_mask, 0, B44_PMASK_SIZE); |
1531 | plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, | 1530 | plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, |
1532 | B44_ETHIPV4UDP_HLEN); | 1531 | B44_ETHIPV4UDP_HLEN); |
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c index 7845eaf6f29f..202d4a4ef751 100644 --- a/drivers/net/bsd_comp.c +++ b/drivers/net/bsd_comp.c | |||
@@ -395,14 +395,13 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
395 | * Allocate the main control structure for this instance. | 395 | * Allocate the main control structure for this instance. |
396 | */ | 396 | */ |
397 | maxmaxcode = MAXCODE(bits); | 397 | maxmaxcode = MAXCODE(bits); |
398 | db = kmalloc(sizeof (struct bsd_db), | 398 | db = kzalloc(sizeof (struct bsd_db), |
399 | GFP_KERNEL); | 399 | GFP_KERNEL); |
400 | if (!db) | 400 | if (!db) |
401 | { | 401 | { |
402 | return NULL; | 402 | return NULL; |
403 | } | 403 | } |
404 | 404 | ||
405 | memset (db, 0, sizeof(struct bsd_db)); | ||
406 | /* | 405 | /* |
407 | * Allocate space for the dictionary. This may be more than one page in | 406 | * Allocate space for the dictionary. This may be more than one page in |
408 | * length. | 407 | * length. |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 136827f8dc2e..6d1d50a19783 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -5137,12 +5137,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
5137 | goto out_unmap; | 5137 | goto out_unmap; |
5138 | np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size]; | 5138 | np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size]; |
5139 | } | 5139 | } |
5140 | np->rx_skb = kmalloc(sizeof(struct nv_skb_map) * np->rx_ring_size, GFP_KERNEL); | 5140 | np->rx_skb = kcalloc(np->rx_ring_size, sizeof(struct nv_skb_map), GFP_KERNEL); |
5141 | np->tx_skb = kmalloc(sizeof(struct nv_skb_map) * np->tx_ring_size, GFP_KERNEL); | 5141 | np->tx_skb = kcalloc(np->tx_ring_size, sizeof(struct nv_skb_map), GFP_KERNEL); |
5142 | if (!np->rx_skb || !np->tx_skb) | 5142 | if (!np->rx_skb || !np->tx_skb) |
5143 | goto out_freering; | 5143 | goto out_freering; |
5144 | memset(np->rx_skb, 0, sizeof(struct nv_skb_map) * np->rx_ring_size); | ||
5145 | memset(np->tx_skb, 0, sizeof(struct nv_skb_map) * np->tx_ring_size); | ||
5146 | 5144 | ||
5147 | dev->open = nv_open; | 5145 | dev->open = nv_open; |
5148 | dev->stop = nv_close; | 5146 | dev->stop = nv_close; |
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index 3be8c5047599..205f09672492 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c | |||
@@ -453,8 +453,8 @@ static int __init setup_adapter(int card_base, int type, int n) | |||
453 | int scc_base = card_base + hw[type].scc_offset; | 453 | int scc_base = card_base + hw[type].scc_offset; |
454 | char *chipnames[] = CHIPNAMES; | 454 | char *chipnames[] = CHIPNAMES; |
455 | 455 | ||
456 | /* Allocate memory */ | 456 | /* Initialize what is necessary for write_scc and write_scc_data */ |
457 | info = kmalloc(sizeof(struct scc_info), GFP_KERNEL | GFP_DMA); | 457 | info = kzalloc(sizeof(struct scc_info), GFP_KERNEL | GFP_DMA); |
458 | if (!info) { | 458 | if (!info) { |
459 | printk(KERN_ERR "dmascc: " | 459 | printk(KERN_ERR "dmascc: " |
460 | "could not allocate memory for %s at %#3x\n", | 460 | "could not allocate memory for %s at %#3x\n", |
@@ -462,8 +462,6 @@ static int __init setup_adapter(int card_base, int type, int n) | |||
462 | goto out; | 462 | goto out; |
463 | } | 463 | } |
464 | 464 | ||
465 | /* Initialize what is necessary for write_scc and write_scc_data */ | ||
466 | memset(info, 0, sizeof(struct scc_info)); | ||
467 | 465 | ||
468 | info->dev[0] = alloc_netdev(0, "", dev_setup); | 466 | info->dev[0] = alloc_netdev(0, "", dev_setup); |
469 | if (!info->dev[0]) { | 467 | if (!info->dev[0]) { |
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c index 3078c419cb02..20732458f5ac 100644 --- a/drivers/net/irda/irport.c +++ b/drivers/net/irda/irport.c | |||
@@ -164,14 +164,13 @@ irport_open(int i, unsigned int iobase, unsigned int irq) | |||
164 | 164 | ||
165 | /* Allocate memory if needed */ | 165 | /* Allocate memory if needed */ |
166 | if (self->tx_buff.truesize > 0) { | 166 | if (self->tx_buff.truesize > 0) { |
167 | self->tx_buff.head = kmalloc(self->tx_buff.truesize, | 167 | self->tx_buff.head = kzalloc(self->tx_buff.truesize, |
168 | GFP_KERNEL); | 168 | GFP_KERNEL); |
169 | if (self->tx_buff.head == NULL) { | 169 | if (self->tx_buff.head == NULL) { |
170 | IRDA_ERROR("%s(), can't allocate memory for " | 170 | IRDA_ERROR("%s(), can't allocate memory for " |
171 | "transmit buffer!\n", __FUNCTION__); | 171 | "transmit buffer!\n", __FUNCTION__); |
172 | goto err_out4; | 172 | goto err_out4; |
173 | } | 173 | } |
174 | memset(self->tx_buff.head, 0, self->tx_buff.truesize); | ||
175 | } | 174 | } |
176 | self->tx_buff.data = self->tx_buff.head; | 175 | self->tx_buff.data = self->tx_buff.head; |
177 | 176 | ||
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c index ad1857364d51..6f5f697ec9f8 100644 --- a/drivers/net/irda/irtty-sir.c +++ b/drivers/net/irda/irtty-sir.c | |||
@@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct *tty) | |||
505 | } | 505 | } |
506 | 506 | ||
507 | /* allocate private device info block */ | 507 | /* allocate private device info block */ |
508 | priv = kmalloc(sizeof(*priv), GFP_KERNEL); | 508 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
509 | if (!priv) | 509 | if (!priv) |
510 | goto out_put; | 510 | goto out_put; |
511 | memset(priv, 0, sizeof(*priv)); | ||
512 | 511 | ||
513 | priv->magic = IRTTY_MAGIC; | 512 | priv->magic = IRTTY_MAGIC; |
514 | priv->tty = tty; | 513 | priv->tty = tty; |
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c index 347d50cd77d4..0433c41f9029 100644 --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c | |||
@@ -822,10 +822,9 @@ static int veth_init_connection(u8 rlp) | |||
822 | || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) ) | 822 | || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) ) |
823 | return 0; | 823 | return 0; |
824 | 824 | ||
825 | cnx = kmalloc(sizeof(*cnx), GFP_KERNEL); | 825 | cnx = kzalloc(sizeof(*cnx), GFP_KERNEL); |
826 | if (! cnx) | 826 | if (! cnx) |
827 | return -ENOMEM; | 827 | return -ENOMEM; |
828 | memset(cnx, 0, sizeof(*cnx)); | ||
829 | 828 | ||
830 | cnx->remote_lp = rlp; | 829 | cnx->remote_lp = rlp; |
831 | spin_lock_init(&cnx->lock); | 830 | spin_lock_init(&cnx->lock); |
@@ -852,14 +851,13 @@ static int veth_init_connection(u8 rlp) | |||
852 | if (rc != 0) | 851 | if (rc != 0) |
853 | return rc; | 852 | return rc; |
854 | 853 | ||
855 | msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL); | 854 | msgs = kcalloc(VETH_NUMBUFFERS, sizeof(struct veth_msg), GFP_KERNEL); |
856 | if (! msgs) { | 855 | if (! msgs) { |
857 | veth_error("Can't allocate buffers for LPAR %d.\n", rlp); | 856 | veth_error("Can't allocate buffers for LPAR %d.\n", rlp); |
858 | return -ENOMEM; | 857 | return -ENOMEM; |
859 | } | 858 | } |
860 | 859 | ||
861 | cnx->msgs = msgs; | 860 | cnx->msgs = msgs; |
862 | memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg)); | ||
863 | 861 | ||
864 | for (i = 0; i < VETH_NUMBUFFERS; i++) { | 862 | for (i = 0; i < VETH_NUMBUFFERS; i++) { |
865 | msgs[i].token = i; | 863 | msgs[i].token = i; |
diff --git a/drivers/net/lance.c b/drivers/net/lance.c index a2f37e52b928..a4e5fab12628 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c | |||
@@ -533,11 +533,10 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int | |||
533 | dev->base_addr = ioaddr; | 533 | dev->base_addr = ioaddr; |
534 | /* Make certain the data structures used by the LANCE are aligned and DMAble. */ | 534 | /* Make certain the data structures used by the LANCE are aligned and DMAble. */ |
535 | 535 | ||
536 | lp = kmalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL); | 536 | lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL); |
537 | if(lp==NULL) | 537 | if(lp==NULL) |
538 | return -ENODEV; | 538 | return -ENODEV; |
539 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); | 539 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); |
540 | memset(lp, 0, sizeof(*lp)); | ||
541 | dev->priv = lp; | 540 | dev->priv = lp; |
542 | lp->name = chipname; | 541 | lp->name = chipname; |
543 | lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, | 542 | lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, |
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 0d1c7a41c9c6..ea9414c4d900 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c | |||
@@ -147,7 +147,7 @@ static int com20020_probe(struct pcmcia_device *p_dev) | |||
147 | DEBUG(0, "com20020_attach()\n"); | 147 | DEBUG(0, "com20020_attach()\n"); |
148 | 148 | ||
149 | /* Create new network device */ | 149 | /* Create new network device */ |
150 | info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); | 150 | info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); |
151 | if (!info) | 151 | if (!info) |
152 | goto fail_alloc_info; | 152 | goto fail_alloc_info; |
153 | 153 | ||
@@ -155,7 +155,6 @@ static int com20020_probe(struct pcmcia_device *p_dev) | |||
155 | if (!dev) | 155 | if (!dev) |
156 | goto fail_alloc_dev; | 156 | goto fail_alloc_dev; |
157 | 157 | ||
158 | memset(info, 0, sizeof(struct com20020_dev_t)); | ||
159 | lp = dev->priv; | 158 | lp = dev->priv; |
160 | lp->timeout = timeout; | 159 | lp->timeout = timeout; |
161 | lp->backplane = backplane; | 160 | lp->backplane = backplane; |
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 4ecb8ca5a992..4eafa4f42cff 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c | |||
@@ -146,9 +146,8 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link) | |||
146 | DEBUG(0, "ibmtr_attach()\n"); | 146 | DEBUG(0, "ibmtr_attach()\n"); |
147 | 147 | ||
148 | /* Create new token-ring device */ | 148 | /* Create new token-ring device */ |
149 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 149 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
150 | if (!info) return -ENOMEM; | 150 | if (!info) return -ENOMEM; |
151 | memset(info,0,sizeof(*info)); | ||
152 | dev = alloc_trdev(sizeof(struct tok_info)); | 151 | dev = alloc_trdev(sizeof(struct tok_info)); |
153 | if (!dev) { | 152 | if (!dev) { |
154 | kfree(info); | 153 | kfree(info); |
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c index caabbc408c34..27f5b904f48e 100644 --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c | |||
@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty) | |||
159 | int err; | 159 | int err; |
160 | 160 | ||
161 | err = -ENOMEM; | 161 | err = -ENOMEM; |
162 | ap = kmalloc(sizeof(*ap), GFP_KERNEL); | 162 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
163 | if (ap == 0) | 163 | if (ap == 0) |
164 | goto out; | 164 | goto out; |
165 | 165 | ||
166 | /* initialize the asyncppp structure */ | 166 | /* initialize the asyncppp structure */ |
167 | memset(ap, 0, sizeof(*ap)); | ||
168 | ap->tty = tty; | 167 | ap->tty = tty; |
169 | ap->mru = PPP_MRU; | 168 | ap->mru = PPP_MRU; |
170 | spin_lock_init(&ap->xmit_lock); | 169 | spin_lock_init(&ap->xmit_lock); |
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c index 72c8d6628f58..eb98b661efba 100644 --- a/drivers/net/ppp_deflate.c +++ b/drivers/net/ppp_deflate.c | |||
@@ -121,12 +121,11 @@ static void *z_comp_alloc(unsigned char *options, int opt_len) | |||
121 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) | 121 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) |
122 | return NULL; | 122 | return NULL; |
123 | 123 | ||
124 | state = kmalloc(sizeof(*state), | 124 | state = kzalloc(sizeof(*state), |
125 | GFP_KERNEL); | 125 | GFP_KERNEL); |
126 | if (state == NULL) | 126 | if (state == NULL) |
127 | return NULL; | 127 | return NULL; |
128 | 128 | ||
129 | memset (state, 0, sizeof (struct ppp_deflate_state)); | ||
130 | state->strm.next_in = NULL; | 129 | state->strm.next_in = NULL; |
131 | state->w_size = w_size; | 130 | state->w_size = w_size; |
132 | state->strm.workspace = vmalloc(zlib_deflate_workspacesize()); | 131 | state->strm.workspace = vmalloc(zlib_deflate_workspacesize()); |
@@ -341,11 +340,10 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len) | |||
341 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) | 340 | if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) |
342 | return NULL; | 341 | return NULL; |
343 | 342 | ||
344 | state = kmalloc(sizeof(*state), GFP_KERNEL); | 343 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
345 | if (state == NULL) | 344 | if (state == NULL) |
346 | return NULL; | 345 | return NULL; |
347 | 346 | ||
348 | memset (state, 0, sizeof (struct ppp_deflate_state)); | ||
349 | state->w_size = w_size; | 347 | state->w_size = w_size; |
350 | state->strm.next_out = NULL; | 348 | state->strm.next_out = NULL; |
351 | state->strm.workspace = kmalloc(zlib_inflate_workspacesize(), | 349 | state->strm.workspace = kmalloc(zlib_inflate_workspacesize(), |
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index d5bdd2574659..f79cf87a2bff 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
@@ -200,11 +200,10 @@ static void *mppe_alloc(unsigned char *options, int optlen) | |||
200 | || options[0] != CI_MPPE || options[1] != CILEN_MPPE) | 200 | || options[0] != CI_MPPE || options[1] != CILEN_MPPE) |
201 | goto out; | 201 | goto out; |
202 | 202 | ||
203 | state = kmalloc(sizeof(*state), GFP_KERNEL); | 203 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
204 | if (state == NULL) | 204 | if (state == NULL) |
205 | goto out; | 205 | goto out; |
206 | 206 | ||
207 | memset(state, 0, sizeof(*state)); | ||
208 | 207 | ||
209 | state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); | 208 | state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
210 | if (IS_ERR(state->arc4)) { | 209 | if (IS_ERR(state->arc4)) { |
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c index 5918fab38349..ce64032a465a 100644 --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c | |||
@@ -207,13 +207,12 @@ ppp_sync_open(struct tty_struct *tty) | |||
207 | struct syncppp *ap; | 207 | struct syncppp *ap; |
208 | int err; | 208 | int err; |
209 | 209 | ||
210 | ap = kmalloc(sizeof(*ap), GFP_KERNEL); | 210 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
211 | err = -ENOMEM; | 211 | err = -ENOMEM; |
212 | if (ap == 0) | 212 | if (ap == 0) |
213 | goto out; | 213 | goto out; |
214 | 214 | ||
215 | /* initialize the syncppp structure */ | 215 | /* initialize the syncppp structure */ |
216 | memset(ap, 0, sizeof(*ap)); | ||
217 | ap->tty = tty; | 216 | ap->tty = tty; |
218 | ap->mru = PPP_MRU; | 217 | ap->mru = PPP_MRU; |
219 | spin_lock_init(&ap->xmit_lock); | 218 | spin_lock_init(&ap->xmit_lock); |
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index e886e8d7cfdf..4c3d98ff4cd4 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c | |||
@@ -600,10 +600,9 @@ static int __init shaper_init(void) | |||
600 | return -ENODEV; | 600 | return -ENODEV; |
601 | 601 | ||
602 | alloc_size = sizeof(*dev) * shapers; | 602 | alloc_size = sizeof(*dev) * shapers; |
603 | devs = kmalloc(alloc_size, GFP_KERNEL); | 603 | devs = kzalloc(alloc_size, GFP_KERNEL); |
604 | if (!devs) | 604 | if (!devs) |
605 | return -ENOMEM; | 605 | return -ENOMEM; |
606 | memset(devs, 0, alloc_size); | ||
607 | 606 | ||
608 | for (i = 0; i < shapers; i++) { | 607 | for (i = 0; i < shapers; i++) { |
609 | 608 | ||
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 6b63b350cd52..8ead774d14c8 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c | |||
@@ -315,12 +315,11 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) | |||
315 | return -ENODEV; | 315 | return -ENODEV; |
316 | } | 316 | } |
317 | 317 | ||
318 | card = kmalloc(sizeof(card_t), GFP_KERNEL); | 318 | card = kzalloc(sizeof(card_t), GFP_KERNEL); |
319 | if (card == NULL) { | 319 | if (card == NULL) { |
320 | printk(KERN_ERR "c101: unable to allocate memory\n"); | 320 | printk(KERN_ERR "c101: unable to allocate memory\n"); |
321 | return -ENOBUFS; | 321 | return -ENOBUFS; |
322 | } | 322 | } |
323 | memset(card, 0, sizeof(card_t)); | ||
324 | 323 | ||
325 | card->dev = alloc_hdlcdev(card); | 324 | card->dev = alloc_hdlcdev(card); |
326 | if (!card->dev) { | 325 | if (!card->dev) { |
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 9ef49ce148b2..26058b4f8f36 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -572,13 +572,11 @@ static int cosa_probe(int base, int irq, int dma) | |||
572 | sprintf(cosa->name, "cosa%d", cosa->num); | 572 | sprintf(cosa->name, "cosa%d", cosa->num); |
573 | 573 | ||
574 | /* Initialize the per-channel data */ | 574 | /* Initialize the per-channel data */ |
575 | cosa->chan = kmalloc(sizeof(struct channel_data)*cosa->nchannels, | 575 | cosa->chan = kcalloc(cosa->nchannels, sizeof(struct channel_data), GFP_KERNEL); |
576 | GFP_KERNEL); | ||
577 | if (!cosa->chan) { | 576 | if (!cosa->chan) { |
578 | err = -ENOMEM; | 577 | err = -ENOMEM; |
579 | goto err_out3; | 578 | goto err_out3; |
580 | } | 579 | } |
581 | memset(cosa->chan, 0, sizeof(struct channel_data)*cosa->nchannels); | ||
582 | for (i=0; i<cosa->nchannels; i++) { | 580 | for (i=0; i<cosa->nchannels; i++) { |
583 | cosa->chan[i].cosa = cosa; | 581 | cosa->chan[i].cosa = cosa; |
584 | cosa->chan[i].num = i; | 582 | cosa->chan[i].num = i; |
diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c index 6e5f1c898517..a0e8611ad8e8 100644 --- a/drivers/net/wan/cycx_main.c +++ b/drivers/net/wan/cycx_main.c | |||
@@ -113,12 +113,10 @@ static int __init cycx_init(void) | |||
113 | /* Verify number of cards and allocate adapter data space */ | 113 | /* Verify number of cards and allocate adapter data space */ |
114 | cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS); | 114 | cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS); |
115 | cycx_ncards = max_t(int, cycx_ncards, 1); | 115 | cycx_ncards = max_t(int, cycx_ncards, 1); |
116 | cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards, | 116 | cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device), GFP_KERNEL); |
117 | GFP_KERNEL); | ||
118 | if (!cycx_card_array) | 117 | if (!cycx_card_array) |
119 | goto out; | 118 | goto out; |
120 | 119 | ||
121 | memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards); | ||
122 | 120 | ||
123 | /* Register adapters with WAN router */ | 121 | /* Register adapters with WAN router */ |
124 | for (cnt = 0; cnt < cycx_ncards; ++cnt) { | 122 | for (cnt = 0; cnt < cycx_ncards; ++cnt) { |
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index 016b3ff3ea5e..a8af28b273d3 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c | |||
@@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev, | |||
376 | } | 376 | } |
377 | 377 | ||
378 | /* allocate and initialize private data */ | 378 | /* allocate and initialize private data */ |
379 | chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); | 379 | chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); |
380 | if (!chan) | 380 | if (!chan) |
381 | return -ENOMEM; | 381 | return -ENOMEM; |
382 | 382 | ||
383 | memset(chan, 0, sizeof(*chan)); | ||
384 | strcpy(chan->name, conf->name); | 383 | strcpy(chan->name, conf->name); |
385 | chan->card = card; | 384 | chan->card = card; |
386 | chan->link = conf->port; | 385 | chan->link = conf->port; |
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index dca024471455..50d2f9108dca 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c | |||
@@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) | |||
890 | struct dscc4_dev_priv *root; | 890 | struct dscc4_dev_priv *root; |
891 | int i, ret = -ENOMEM; | 891 | int i, ret = -ENOMEM; |
892 | 892 | ||
893 | root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL); | 893 | root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL); |
894 | if (!root) { | 894 | if (!root) { |
895 | printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); | 895 | printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); |
896 | goto err_out; | 896 | goto err_out; |
897 | } | 897 | } |
898 | memset(root, 0, dev_per_card*sizeof(*root)); | ||
899 | 898 | ||
900 | for (i = 0; i < dev_per_card; i++) { | 899 | for (i = 0; i < dev_per_card; i++) { |
901 | root[i].dev = alloc_hdlcdev(root + i); | 900 | root[i].dev = alloc_hdlcdev(root + i); |
@@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) | |||
903 | goto err_free_dev; | 902 | goto err_free_dev; |
904 | } | 903 | } |
905 | 904 | ||
906 | ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL); | 905 | ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL); |
907 | if (!ppriv) { | 906 | if (!ppriv) { |
908 | printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); | 907 | printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); |
909 | goto err_free_dev; | 908 | goto err_free_dev; |
910 | } | 909 | } |
911 | memset(ppriv, 0, sizeof(struct dscc4_pci_priv)); | ||
912 | 910 | ||
913 | ppriv->root = root; | 911 | ppriv->root = root; |
914 | spin_lock_init(&ppriv->lock); | 912 | spin_lock_init(&ppriv->lock); |
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 58a53b6d9b42..12dae8e24844 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c | |||
@@ -2476,13 +2476,12 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2476 | } | 2476 | } |
2477 | 2477 | ||
2478 | /* Allocate driver private data */ | 2478 | /* Allocate driver private data */ |
2479 | card = kmalloc(sizeof (struct fst_card_info), GFP_KERNEL); | 2479 | card = kzalloc(sizeof (struct fst_card_info), GFP_KERNEL); |
2480 | if (card == NULL) { | 2480 | if (card == NULL) { |
2481 | printk_err("FarSync card found but insufficient memory for" | 2481 | printk_err("FarSync card found but insufficient memory for" |
2482 | " driver storage\n"); | 2482 | " driver storage\n"); |
2483 | return -ENOMEM; | 2483 | return -ENOMEM; |
2484 | } | 2484 | } |
2485 | memset(card, 0, sizeof (struct fst_card_info)); | ||
2486 | 2485 | ||
2487 | /* Try to enable the device */ | 2486 | /* Try to enable the device */ |
2488 | if ((err = pci_enable_device(pdev)) != 0) { | 2487 | if ((err = pci_enable_device(pdev)) != 0) { |
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c index 9ba3e4ee6ec7..bf5f8d9b5c83 100644 --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c | |||
@@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int iobase, int irq) | |||
231 | return NULL; | 231 | return NULL; |
232 | } | 232 | } |
233 | 233 | ||
234 | sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL); | 234 | sv = kzalloc(sizeof(struct sv11_device), GFP_KERNEL); |
235 | if(!sv) | 235 | if(!sv) |
236 | goto fail3; | 236 | goto fail3; |
237 | 237 | ||
238 | memset(sv, 0, sizeof(*sv)); | ||
239 | sv->if_ptr=&sv->netdev; | 238 | sv->if_ptr=&sv->netdev; |
240 | 239 | ||
241 | sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup); | 240 | sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup); |
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index 5c322dfb79f6..cbdf0b748bde 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c | |||
@@ -351,12 +351,11 @@ static int __init n2_run(unsigned long io, unsigned long irq, | |||
351 | return -ENODEV; | 351 | return -ENODEV; |
352 | } | 352 | } |
353 | 353 | ||
354 | card = kmalloc(sizeof(card_t), GFP_KERNEL); | 354 | card = kzalloc(sizeof(card_t), GFP_KERNEL); |
355 | if (card == NULL) { | 355 | if (card == NULL) { |
356 | printk(KERN_ERR "n2: unable to allocate memory\n"); | 356 | printk(KERN_ERR "n2: unable to allocate memory\n"); |
357 | return -ENOBUFS; | 357 | return -ENOBUFS; |
358 | } | 358 | } |
359 | memset(card, 0, sizeof(card_t)); | ||
360 | 359 | ||
361 | card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); | 360 | card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); |
362 | card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); | 361 | card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); |
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 5d8c78ee2cd9..99fee2f1d019 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c | |||
@@ -3456,7 +3456,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3456 | if ((err = pci_enable_device(pdev)) < 0) | 3456 | if ((err = pci_enable_device(pdev)) < 0) |
3457 | return err; | 3457 | return err; |
3458 | 3458 | ||
3459 | card = kmalloc(sizeof(pc300_t), GFP_KERNEL); | 3459 | card = kzalloc(sizeof(pc300_t), GFP_KERNEL); |
3460 | if (card == NULL) { | 3460 | if (card == NULL) { |
3461 | printk("PC300 found at RAM 0x%016llx, " | 3461 | printk("PC300 found at RAM 0x%016llx, " |
3462 | "but could not allocate card structure.\n", | 3462 | "but could not allocate card structure.\n", |
@@ -3464,7 +3464,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3464 | err = -ENOMEM; | 3464 | err = -ENOMEM; |
3465 | goto err_disable_dev; | 3465 | goto err_disable_dev; |
3466 | } | 3466 | } |
3467 | memset(card, 0, sizeof(pc300_t)); | ||
3468 | 3467 | ||
3469 | err = -ENODEV; | 3468 | err = -ENODEV; |
3470 | 3469 | ||
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c index dfbd3b00f03b..6353cb5c658d 100644 --- a/drivers/net/wan/pc300too.c +++ b/drivers/net/wan/pc300too.c | |||
@@ -334,14 +334,13 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, | |||
334 | return i; | 334 | return i; |
335 | } | 335 | } |
336 | 336 | ||
337 | card = kmalloc(sizeof(card_t), GFP_KERNEL); | 337 | card = kzalloc(sizeof(card_t), GFP_KERNEL); |
338 | if (card == NULL) { | 338 | if (card == NULL) { |
339 | printk(KERN_ERR "pc300: unable to allocate memory\n"); | 339 | printk(KERN_ERR "pc300: unable to allocate memory\n"); |
340 | pci_release_regions(pdev); | 340 | pci_release_regions(pdev); |
341 | pci_disable_device(pdev); | 341 | pci_disable_device(pdev); |
342 | return -ENOBUFS; | 342 | return -ENOBUFS; |
343 | } | 343 | } |
344 | memset(card, 0, sizeof(card_t)); | ||
345 | pci_set_drvdata(pdev, card); | 344 | pci_set_drvdata(pdev, card); |
346 | 345 | ||
347 | if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 || | 346 | if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 || |
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c index 7f720de2e9f0..092e51d89036 100644 --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c | |||
@@ -312,14 +312,13 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, | |||
312 | return i; | 312 | return i; |
313 | } | 313 | } |
314 | 314 | ||
315 | card = kmalloc(sizeof(card_t), GFP_KERNEL); | 315 | card = kzalloc(sizeof(card_t), GFP_KERNEL); |
316 | if (card == NULL) { | 316 | if (card == NULL) { |
317 | printk(KERN_ERR "pci200syn: unable to allocate memory\n"); | 317 | printk(KERN_ERR "pci200syn: unable to allocate memory\n"); |
318 | pci_release_regions(pdev); | 318 | pci_release_regions(pdev); |
319 | pci_disable_device(pdev); | 319 | pci_disable_device(pdev); |
320 | return -ENOBUFS; | 320 | return -ENOBUFS; |
321 | } | 321 | } |
322 | memset(card, 0, sizeof(card_t)); | ||
323 | pci_set_drvdata(pdev, card); | 322 | pci_set_drvdata(pdev, card); |
324 | card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); | 323 | card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); |
325 | card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); | 324 | card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); |
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c index 6a485f0556f4..792e588d7d61 100644 --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c | |||
@@ -1196,10 +1196,9 @@ static int sdla_xfer(struct net_device *dev, struct sdla_mem __user *info, int r | |||
1196 | 1196 | ||
1197 | if (read) | 1197 | if (read) |
1198 | { | 1198 | { |
1199 | temp = kmalloc(mem.len, GFP_KERNEL); | 1199 | temp = kzalloc(mem.len, GFP_KERNEL); |
1200 | if (!temp) | 1200 | if (!temp) |
1201 | return(-ENOMEM); | 1201 | return(-ENOMEM); |
1202 | memset(temp, 0, mem.len); | ||
1203 | sdla_read(dev, mem.addr, temp, mem.len); | 1202 | sdla_read(dev, mem.addr, temp, mem.len); |
1204 | if(copy_to_user(mem.data, temp, mem.len)) | 1203 | if(copy_to_user(mem.data, temp, mem.len)) |
1205 | { | 1204 | { |
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c index 131358108c5a..11276bf3149f 100644 --- a/drivers/net/wan/sealevel.c +++ b/drivers/net/wan/sealevel.c | |||
@@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_init(int iobase, int irq, | |||
270 | return NULL; | 270 | return NULL; |
271 | } | 271 | } |
272 | 272 | ||
273 | b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL); | 273 | b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL); |
274 | if(!b) | 274 | if(!b) |
275 | goto fail3; | 275 | goto fail3; |
276 | 276 | ||
277 | memset(b, 0, sizeof(*b)); | ||
278 | if (!(b->dev[0]= slvl_alloc(iobase, irq))) | 277 | if (!(b->dev[0]= slvl_alloc(iobase, irq))) |
279 | goto fail2; | 278 | goto fail2; |
280 | 279 | ||
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index c73601574334..3c78f9856380 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c | |||
@@ -599,7 +599,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, | |||
599 | } | 599 | } |
600 | 600 | ||
601 | alloc_size = sizeof(card_t) + ports * sizeof(port_t); | 601 | alloc_size = sizeof(card_t) + ports * sizeof(port_t); |
602 | card = kmalloc(alloc_size, GFP_KERNEL); | 602 | card = kzalloc(alloc_size, GFP_KERNEL); |
603 | if (card == NULL) { | 603 | if (card == NULL) { |
604 | printk(KERN_ERR "wanXL %s: unable to allocate memory\n", | 604 | printk(KERN_ERR "wanXL %s: unable to allocate memory\n", |
605 | pci_name(pdev)); | 605 | pci_name(pdev)); |
@@ -607,7 +607,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, | |||
607 | pci_disable_device(pdev); | 607 | pci_disable_device(pdev); |
608 | return -ENOBUFS; | 608 | return -ENOBUFS; |
609 | } | 609 | } |
610 | memset(card, 0, alloc_size); | ||
611 | 610 | ||
612 | pci_set_drvdata(pdev, card); | 611 | pci_set_drvdata(pdev, card); |
613 | card->pdev = pdev; | 612 | card->pdev = pdev; |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 1c9edd97accd..c48b1cc63fd5 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -786,14 +786,12 @@ static int __init init_x25_asy(void) | |||
786 | printk(KERN_INFO "X.25 async: version 0.00 ALPHA " | 786 | printk(KERN_INFO "X.25 async: version 0.00 ALPHA " |
787 | "(dynamic channels, max=%d).\n", x25_asy_maxdev ); | 787 | "(dynamic channels, max=%d).\n", x25_asy_maxdev ); |
788 | 788 | ||
789 | x25_asy_devs = kmalloc(sizeof(struct net_device *)*x25_asy_maxdev, | 789 | x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device*), GFP_KERNEL); |
790 | GFP_KERNEL); | ||
791 | if (!x25_asy_devs) { | 790 | if (!x25_asy_devs) { |
792 | printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " | 791 | printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " |
793 | "array! Uaargh! (-> No X.25 available)\n"); | 792 | "array! Uaargh! (-> No X.25 available)\n"); |
794 | return -ENOMEM; | 793 | return -ENOMEM; |
795 | } | 794 | } |
796 | memset(x25_asy_devs, 0, sizeof(struct net_device *)*x25_asy_maxdev); | ||
797 | 795 | ||
798 | return tty_register_ldisc(N_X25, &x25_ldisc); | 796 | return tty_register_ldisc(N_X25, &x25_ldisc); |
799 | } | 797 | } |