summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKulikov Vasiliy <segooon@gmail.com>2010-07-12 04:52:33 (GMT)
committerDavid S. Miller <davem@davemloft.net>2010-07-13 03:21:40 (GMT)
commit84c3b972f37a735dafc25c4c0d5fb98f99e1157a (patch)
tree0d0cee22f554ec4d402d67e5560ac1dcfaf284b4 /drivers
parent9e34a5b51684bc90ac827ec4ba339f3892632eac (diff)
downloadlinux-fsl-qoriq-84c3b972f37a735dafc25c4c0d5fb98f99e1157a.tar.xz
depca: fix leaks in depca_module_init()
Since some of xxx_register_driver() can return error we must unregister already registered drivers. Signed-off-by: Kulikov Vasiliy <segooon@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/depca.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index bf66e9b..44c0694 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -2061,18 +2061,35 @@ static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
static int __init depca_module_init (void)
{
- int err = 0;
+ int err = 0;
#ifdef CONFIG_MCA
- err = mca_register_driver (&depca_mca_driver);
+ err = mca_register_driver(&depca_mca_driver);
+ if (err)
+ goto err;
#endif
#ifdef CONFIG_EISA
- err |= eisa_driver_register (&depca_eisa_driver);
+ err = eisa_driver_register(&depca_eisa_driver);
+ if (err)
+ goto err_mca;
#endif
- err |= platform_driver_register (&depca_isa_driver);
- depca_platform_probe ();
+ err = platform_driver_register(&depca_isa_driver);
+ if (err)
+ goto err_eisa;
- return err;
+ depca_platform_probe();
+ return 0;
+
+err_eisa:
+#ifdef CONFIG_EISA
+ eisa_driver_unregister(&depca_eisa_driver);
+err_mca:
+#endif
+#ifdef CONFIG_MCA
+ mca_unregister_driver(&depca_mca_driver);
+err:
+#endif
+ return err;
}
static void __exit depca_module_exit (void)