Commit 2845b63b authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Arnaldo Carvalho de Melo

[PKTGEN]: Use kzalloc

These are cleanup patches for pktgen that can go in 2.6.15
Can use kzalloc in a couple of places.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarRobert Olsson <robert.olsson@its.uu.se>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent b7c8921b
...@@ -2869,12 +2869,10 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) ...@@ -2869,12 +2869,10 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname)
if( (pkt_dev = __pktgen_NN_threads(ifname, FIND)) == NULL) { if( (pkt_dev = __pktgen_NN_threads(ifname, FIND)) == NULL) {
pkt_dev = kmalloc(sizeof(struct pktgen_dev), GFP_KERNEL); pkt_dev = kzalloc(sizeof(struct pktgen_dev), GFP_KERNEL);
if (!pkt_dev) if (!pkt_dev)
return -ENOMEM; return -ENOMEM;
memset(pkt_dev, 0, sizeof(struct pktgen_dev));
pkt_dev->flows = vmalloc(MAX_CFLOWS*sizeof(struct flow_state)); pkt_dev->flows = vmalloc(MAX_CFLOWS*sizeof(struct flow_state));
if (pkt_dev->flows == NULL) { if (pkt_dev->flows == NULL) {
kfree(pkt_dev); kfree(pkt_dev);
...@@ -2958,13 +2956,12 @@ static int pktgen_create_thread(const char* name, int cpu) ...@@ -2958,13 +2956,12 @@ static int pktgen_create_thread(const char* name, int cpu)
return -EINVAL; return -EINVAL;
} }
t = (struct pktgen_thread*)(kmalloc(sizeof(struct pktgen_thread), GFP_KERNEL)); t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL);
if (!t) { if (!t) {
printk("pktgen: ERROR: out of memory, can't create new thread.\n"); printk("pktgen: ERROR: out of memory, can't create new thread.\n");
return -ENOMEM; return -ENOMEM;
} }
memset(t, 0, sizeof(struct pktgen_thread));
strcpy(t->name, name); strcpy(t->name, name);
spin_lock_init(&t->if_lock); spin_lock_init(&t->if_lock);
t->cpu = cpu; t->cpu = cpu;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment