Module Name:    src
Committed By:   pgoyette
Date:           Tue Dec 22 23:54:37 UTC 2015

Modified Files:
        src/sys/miscfs/specfs: spec_vnops.c

Log Message:
If we attempt to autoload a driver module, make sure we return an error
if it fails.  Otherwise we might end up calling a builtin-but-disabled
driver module and that can generate all sorts of issues...


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/miscfs/specfs/spec_vnops.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/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.157 src/sys/miscfs/specfs/spec_vnops.c:1.158
--- src/sys/miscfs/specfs/spec_vnops.c:1.157	Tue Dec  8 20:36:15 2015
+++ src/sys/miscfs/specfs/spec_vnops.c	Tue Dec 22 23:54:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: spec_vnops.c,v 1.157 2015/12/08 20:36:15 christos Exp $	*/
+/*	$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.157 2015/12/08 20:36:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.158 2015/12/22 23:54:37 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -573,7 +573,12 @@ spec_open(void *v)
 				break;
 			
 			/* Try to autoload device module */
-			(void) module_autoload(name, MODULE_CLASS_DRIVER);
+			error = module_autoload(name, MODULE_CLASS_DRIVER);
+			if (error != 0) {
+				error = ENXIO;
+				break;
+			}
+
 		} while (gen != module_gen);
 
 		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -624,9 +629,15 @@ spec_open(void *v)
 			VOP_UNLOCK(vp);
 
                         /* Try to autoload device module */
-			(void) module_autoload(name, MODULE_CLASS_DRIVER);
-			
+			error = module_autoload(name, MODULE_CLASS_DRIVER);
+
 			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+
+			if (error != 0) {
+				error = ENXIO;
+				break;
+			}
+			
 		} while (gen != module_gen);
 
 		break;

Reply via email to