Module Name: src
Committed By: maxv
Date: Sun Apr 26 19:31:36 UTC 2020
Modified Files:
src/sys/dev/nvmm: nvmm.c
Log Message:
In nvmm_open(), make sure an implementation was found. This fixes an
initialization bug triggerable in certain conditions.
If you build nvmm inside the kernel, AND have a cpu that is not supported,
AND run nvmmctl (or qemu-nvmm, both being the only binaries in the "nvmm"
group), you get a page fault.
This is because when nvmm is built inside the kernel, the kernel registers
nvmm_cdevsw behind nvmm's back. The ioctl is therefore always accessible,
and will hit NULL pointers if nvmm_init() failed.
Problem reported by Andrei M. on netbsd-users@, thanks.
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/nvmm/nvmm.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/dev/nvmm/nvmm.c
diff -u src/sys/dev/nvmm/nvmm.c:1.25 src/sys/dev/nvmm/nvmm.c:1.26
--- src/sys/dev/nvmm/nvmm.c:1.25 Mon Oct 28 09:00:08 2019
+++ src/sys/dev/nvmm/nvmm.c Sun Apr 26 19:31:36 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.c,v 1.25 2019/10/28 09:00:08 maxv Exp $ */
+/* $NetBSD: nvmm.c,v 1.26 2020/04/26 19:31:36 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.25 2019/10/28 09:00:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.26 2020/04/26 19:31:36 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1040,6 +1040,8 @@ nvmm_open(dev_t dev, int flags, int type
struct file *fp;
int error, fd;
+ if (__predict_false(nvmm_impl == NULL))
+ return ENXIO;
if (minor(dev) != 0)
return EXDEV;
if (!(flags & O_CLOEXEC))