diff options
author | Luiz Capitulino <lcapitulino@mandriva.com.br> | 2006-03-21 01:17:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:17:55 -0500 |
commit | 8024bb245408060bec8393469e945b541a9b0865 (patch) | |
tree | be58db8760c3ca03fc3b71155cf0cd88849ee4be /net/core | |
parent | 12e1872328e7055d06e539f1b687dc3d0610855c (diff) |
[PKTGEN]: Fix Initialization fail leak.
Even if pktgen's thread initialization fails for all CPUs, the module
will be successfully loaded.
This patch changes that behaivor, by returning an error on module load time,
and also freeing all the resources allocated. It also prints a warning if a
thread initialization has failed.
Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index eef1392b7f8e..fda403419ff2 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -3216,11 +3216,24 @@ static int __init pg_init(void) | |||
3216 | register_netdevice_notifier(&pktgen_notifier_block); | 3216 | register_netdevice_notifier(&pktgen_notifier_block); |
3217 | 3217 | ||
3218 | for_each_online_cpu(cpu) { | 3218 | for_each_online_cpu(cpu) { |
3219 | int err; | ||
3219 | char buf[30]; | 3220 | char buf[30]; |
3220 | 3221 | ||
3221 | sprintf(buf, "kpktgend_%i", cpu); | 3222 | sprintf(buf, "kpktgend_%i", cpu); |
3222 | pktgen_create_thread(buf, cpu); | 3223 | err = pktgen_create_thread(buf, cpu); |
3224 | if (err) | ||
3225 | printk("pktgen: WARNING: Cannot create thread for cpu %d (%d)\n", | ||
3226 | cpu, err); | ||
3223 | } | 3227 | } |
3228 | |||
3229 | if (list_empty(&pktgen_threads)) { | ||
3230 | printk("pktgen: ERROR: Initialization failed for all threads\n"); | ||
3231 | unregister_netdevice_notifier(&pktgen_notifier_block); | ||
3232 | remove_proc_entry(PGCTRL, pg_proc_dir); | ||
3233 | proc_net_remove(PG_PROC_DIR); | ||
3234 | return -ENODEV; | ||
3235 | } | ||
3236 | |||
3224 | return 0; | 3237 | return 0; |
3225 | } | 3238 | } |
3226 | 3239 | ||