libata-core: make sure that ata_force_tbl is freed in case of an error
authorElias Oltmanns <eo@nebensachen.de>
Wed, 30 Jul 2008 19:32:39 +0000 (12:32 -0700)
committerJeff Garzik <jgarzik@redhat.com>
Thu, 31 Jul 2008 05:47:12 +0000 (01:47 -0400)
Fix a potential memory leak when ata_init() encounters an error.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/ata/libata-core.c

index 9cd04f684102da0eaa9a2a380b8bfcfa9803b706..f69d1548b562a15111e1bffb1ab5f9e51f2a31ef 100644 (file)
@@ -6098,16 +6098,20 @@ static int __init ata_init(void)
 
        ata_wq = create_workqueue("ata");
        if (!ata_wq)
-               return -ENOMEM;
+               goto free_force_tbl;
 
        ata_aux_wq = create_singlethread_workqueue("ata_aux");
-       if (!ata_aux_wq) {
-               destroy_workqueue(ata_wq);
-               return -ENOMEM;
-       }
+       if (!ata_aux_wq)
+               goto free_wq;
 
        printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
        return 0;
+
+free_wq:
+       destroy_workqueue(ata_wq);
+free_force_tbl:
+       kfree(ata_force_tbl);
+       return -ENOMEM;
 }
 
 static void __exit ata_exit(void)