Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ocfs2: fix leaks on failure exits in module_init

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 342827d7 0794f569

+21 -19
+21 -19
fs/ocfs2/super.c
··· 1624 1624 init_waitqueue_head(&ocfs2__ioend_wq[i]); 1625 1625 1626 1626 status = init_ocfs2_uptodate_cache(); 1627 - if (status < 0) { 1628 - mlog_errno(status); 1629 - goto leave; 1630 - } 1627 + if (status < 0) 1628 + goto out1; 1631 1629 1632 1630 status = ocfs2_initialize_mem_caches(); 1633 - if (status < 0) { 1634 - mlog_errno(status); 1635 - goto leave; 1636 - } 1631 + if (status < 0) 1632 + goto out2; 1637 1633 1638 1634 ocfs2_wq = create_singlethread_workqueue("ocfs2_wq"); 1639 1635 if (!ocfs2_wq) { 1640 1636 status = -ENOMEM; 1641 - goto leave; 1637 + goto out3; 1642 1638 } 1643 1639 1644 1640 ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); ··· 1646 1650 ocfs2_set_locking_protocol(); 1647 1651 1648 1652 status = register_quota_format(&ocfs2_quota_format); 1649 - leave: 1650 - if (status < 0) { 1651 - ocfs2_free_mem_caches(); 1652 - exit_ocfs2_uptodate_cache(); 1653 - mlog_errno(status); 1654 - } 1653 + if (status < 0) 1654 + goto out4; 1655 + status = register_filesystem(&ocfs2_fs_type); 1656 + if (!status) 1657 + return 0; 1655 1658 1656 - if (status >= 0) { 1657 - return register_filesystem(&ocfs2_fs_type); 1658 - } else 1659 - return -1; 1659 + unregister_quota_format(&ocfs2_quota_format); 1660 + out4: 1661 + destroy_workqueue(ocfs2_wq); 1662 + debugfs_remove(ocfs2_debugfs_root); 1663 + out3: 1664 + ocfs2_free_mem_caches(); 1665 + out2: 1666 + exit_ocfs2_uptodate_cache(); 1667 + out1: 1668 + mlog_errno(status); 1669 + return status; 1660 1670 } 1661 1671 1662 1672 static void __exit ocfs2_exit(void)