Module Name:    src
Committed By:   pgoyette
Date:           Mon Jan 27 02:56:15 UTC 2020

Modified Files:
        src/sys/opencrypto: cryptodev.c

Log Message:
If we get an error from devsw_attach(), don't destroy the error value,
since we need to return it to our caller.  While we're here, improve
the value of the debug message by actually printing the error value.


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/opencrypto/cryptodev.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.103 src/sys/opencrypto/cryptodev.c:1.104
--- src/sys/opencrypto/cryptodev.c:1.103	Thu Jan 16 15:29:24 2020
+++ src/sys/opencrypto/cryptodev.c	Mon Jan 27 02:56:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.103 2020/01/16 15:29:24 christos Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.104 2020/01/27 02:56:15 pgoyette Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.103 2020/01/16 15:29:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.104 2020/01/27 02:56:15 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2201,6 +2201,7 @@ crypto_modcmd(modcmd_t cmd, void *arg)
 {
 	int error = 0;
 #ifdef _MODULE
+	int error2;
 	devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
 #endif
 
@@ -2235,14 +2236,14 @@ crypto_modcmd(modcmd_t cmd, void *arg)
 		error = devsw_attach(crypto_cd.cd_name, NULL, &bmajor,
 		    &crypto_cdevsw, &cmajor);
 		if (error) {
-			error = config_cfdata_detach(crypto_cfdata);
-			if (error) {
-				return error;
+			error2 = config_cfdata_detach(crypto_cfdata);
+			if (error2) {
+				return error2;
 			}
 			config_cfattach_detach(crypto_cd.cd_name, &crypto_ca);
 			config_cfdriver_detach(&crypto_cd);
-			aprint_error("%s: unable to register devsw\n",
-				crypto_cd.cd_name);
+			aprint_error("%s: unable to register devsw, error %d\n",
+				crypto_cd.cd_name, error);
 
 			return error;
 		}

Reply via email to