Skip to content

Commit

Permalink
drivers/net: Use kzalloc
Browse files Browse the repository at this point in the history
Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
 if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julia Lawall authored and David S. Miller committed May 18, 2010
1 parent 2e3219b commit beae22e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2608,10 +2608,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
goto out;

ret = -ENOMEM;
msp = kmalloc(sizeof(*msp), GFP_KERNEL);
msp = kzalloc(sizeof(*msp), GFP_KERNEL);
if (msp == NULL)
goto out;
memset(msp, 0, sizeof(*msp));

msp->base = ioremap(res->start, res->end - res->start + 1);
if (msp->base == NULL)
Expand Down

0 comments on commit beae22e

Please sign in to comment.