]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PKTGEN]: Fix kernel_thread() fail leak.
authorLuiz Capitulino <lcapitulino@mandriva.com.br>
Tue, 21 Mar 2006 06:17:00 +0000 (22:17 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Mar 2006 06:17:00 +0000 (22:17 -0800)
Free all the alocated resources if kernel_thread() call fails.

Signed-off-by: Luiz Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index f2c0e965c139b5d44b1d72e6ba30eb16c5955d8b..eef1392b7f8e3e62170ec0df8927dc6b5e1ae0ec 100644 (file)
@@ -3082,6 +3082,7 @@ static struct pktgen_thread *__init pktgen_find_thread(const char *name)
 
 static int __init pktgen_create_thread(const char *name, int cpu)
 {
+       int err;
        struct pktgen_thread *t = NULL;
        struct proc_dir_entry *pe;
 
@@ -3120,9 +3121,15 @@ static int __init pktgen_create_thread(const char *name, int cpu)
 
        t->removed = 0;
 
-       if (kernel_thread((void *)pktgen_thread_worker, (void *)t,
-                         CLONE_FS | CLONE_FILES | CLONE_SIGHAND) < 0)
+       err = kernel_thread((void *)pktgen_thread_worker, (void *)t,
+                         CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
+       if (err < 0) {
                printk("pktgen: kernel_thread() failed for cpu %d\n", t->cpu);
+               remove_proc_entry(t->name, pg_proc_dir);
+               list_del(&t->th_list);
+               kfree(t);
+               return err;
+       }
 
        return 0;
 }