lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1344368886-24033-28-git-send-email-jslaby@suse.cz>
Date:	Tue,  7 Aug 2012 21:47:52 +0200
From:	Jiri Slaby <jslaby@...e.cz>
To:	gregkh@...uxfoundation.org
Cc:	alan@...ux.intel.com, linux-kernel@...r.kernel.org,
	jirislaby@...il.com
Subject: [PATCH 27/41] TTY: synclink_cs, sanitize fail paths

We will need to change the order of tty and pcmcia drivers
initializations (see the reason later in this series). And the fail
path handling is currently performed in a separate function that as
well takes care of proper deinitialization in module_exit. It is hard
to read and will need to be adjusted by our changes anyway. Instead,
get rid of this helper function and do the fail paths handling
directly in the init function. (And move the body of the function to
module_exit.)

Signed-off-by: Jiri Slaby <jslaby@...e.cz>
---
 drivers/char/pcmcia/synclink_cs.c |   41 +++++++++++++------------------------
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index d0cbd29..0606586 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2798,23 +2798,6 @@ static const struct tty_operations mgslpc_ops = {
 	.proc_fops = &mgslpc_proc_fops,
 };
 
-static void synclink_cs_cleanup(void)
-{
-	int rc;
-
-	while(mgslpc_device_list)
-		mgslpc_remove_device(mgslpc_device_list);
-
-	if (serial_driver) {
-		if ((rc = tty_unregister_driver(serial_driver)))
-			printk("%s(%d) failed to unregister tty driver err=%d\n",
-			       __FILE__,__LINE__,rc);
-		put_tty_driver(serial_driver);
-	}
-
-	pcmcia_unregister_driver(&mgslpc_driver);
-}
-
 static int __init synclink_cs_init(void)
 {
     int rc;
@@ -2830,7 +2813,7 @@ static int __init synclink_cs_init(void)
     serial_driver = alloc_tty_driver(MAX_DEVICE_COUNT);
     if (!serial_driver) {
 	    rc = -ENOMEM;
-	    goto error;
+	    goto err_pcmcia_drv;
     }
 
     /* Initialize the tty_driver structure */
@@ -2850,25 +2833,29 @@ static int __init synclink_cs_init(void)
     if ((rc = tty_register_driver(serial_driver)) < 0) {
 	    printk("%s(%d):Couldn't register serial driver\n",
 		   __FILE__,__LINE__);
-	    put_tty_driver(serial_driver);
-	    serial_driver = NULL;
-	    goto error;
+	    goto err_put_tty;
     }
 
     printk("%s %s, tty major#%d\n",
 	   driver_name, driver_version,
 	   serial_driver->major);
 
-    return 0;
-
-error:
-    synclink_cs_cleanup();
-    return rc;
+	return 0;
+err_put_tty:
+	put_tty_driver(serial_driver);
+err_pcmcia_drv:
+	pcmcia_unregister_driver(&mgslpc_driver);
+	return rc;
 }
 
 static void __exit synclink_cs_exit(void)
 {
-	synclink_cs_cleanup();
+	while (mgslpc_device_list)
+		mgslpc_remove_device(mgslpc_device_list);
+
+	tty_unregister_driver(serial_driver);
+	put_tty_driver(serial_driver);
+	pcmcia_unregister_driver(&mgslpc_driver);
 }
 
 module_init(synclink_cs_init);
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ