svn commit: r255857 - head/sys/dev/iscsi

Edward Tomasz Napierala trasz at FreeBSD.org
Tue Sep 24 18:24:02 UTC 2013


Author: trasz
Date: Tue Sep 24 18:24:01 2013
New Revision: 255857
URL: http://svnweb.freebsd.org/changeset/base/255857

Log:
  As it turns out, when MOD_LOAD handler returns error, kernel calls MOD_UNLOAD
  handler.  Make the new iSCSI initiator not panic when this happens.
  
  Approved by:	re (glebius)
  Sponsored by:	FreeBSD Foundation

Modified:
  head/sys/dev/iscsi/iscsi.c

Modified: head/sys/dev/iscsi/iscsi.c
==============================================================================
--- head/sys/dev/iscsi/iscsi.c	Tue Sep 24 17:09:28 2013	(r255856)
+++ head/sys/dev/iscsi/iscsi.c	Tue Sep 24 18:24:01 2013	(r255857)
@@ -2036,10 +2036,6 @@ iscsi_load(void)
 	    NULL, UID_ROOT, GID_WHEEL, 0600, "iscsi");
 	if (error != 0) {
 		ISCSI_WARN("failed to create device node, error %d", error);
-		sx_destroy(&sc->sc_lock);
-		cv_destroy(&sc->sc_cv);
-		uma_zdestroy(iscsi_outstanding_zone);
-		free(sc, M_ISCSI);
 		return (error);
 	}
 	sc->sc_cdev->si_drv1 = sc;
@@ -2056,16 +2052,16 @@ iscsi_load(void)
 static int
 iscsi_unload(void)
 {
-	/*
-	 * XXX: kldunload hangs on "devdrn".
-	 */
 	struct iscsi_session *is, *tmp;
 
-	ISCSI_DEBUG("removing device node");
-	destroy_dev(sc->sc_cdev);
-	ISCSI_DEBUG("device node removed");
+	if (sc->sc_cdev != NULL) {
+		ISCSI_DEBUG("removing device node");
+		destroy_dev(sc->sc_cdev);
+		ISCSI_DEBUG("device node removed");
+	}
 
-	EVENTHANDLER_DEREGISTER(shutdown_post_sync, sc->sc_shutdown_eh);
+	if (sc->sc_shutdown_eh != NULL)
+		EVENTHANDLER_DEREGISTER(shutdown_post_sync, sc->sc_shutdown_eh);
 
 	sx_slock(&sc->sc_lock);
 	TAILQ_FOREACH_SAFE(is, &sc->sc_sessions, is_next, tmp)


More information about the svn-src-all mailing list