libata-core: make sure that ata_force_tbl is freed in case of an error
PATCH 2/2 libata-core: make sure that ata_force_tbl is freed in case of an error
From: Elias Oltmanns <[email protected]>
Fix a potential memory leak when ata_init() encounters an error.
Signed-off-by Elias Oltmanns <[email protected]>
Cc Jeff Garzik <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Alan Cox <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/ata/libata-core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/ata/libata-core.c renamed from drivers/ata/libata-core.c~libata-core-make-sure-that-ata_force_tbl-is-freed-in-case-of-an-error +9 -5
@@ -6088,16 +6088,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)
_
Jeff Garzik
AppliedQuoted 9 lines · [email protected] wrote:
From: Elias Oltmanns <[email protected]>
Fix a potential memory leak when
ata_init()encounters an error.Signed-off-by Elias Oltmanns <[email protected]>Cc Jeff Garzik <[email protected]>Cc Tejun Heo <[email protected]>Cc Alan Cox <[email protected]>Signed-off-by Andrew Morton <[email protected]>
applied