summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2016-04-29 14:40:37 +0000
committerBob Beck <beck@cvs.openbsd.org>2016-04-29 14:40:37 +0000
commitf4bcd1acc00bfdb816780ce4ec8c6a0771db7e48 (patch)
tree9195aa1d7c4e3f2c7634ace105c90bddcedc4f5e /sys/dev
parent3e2a80372cf7ab1ece40b6e7efb0ce2b7ccb409f (diff)
Fix some gibbering horrors due to uninitialized struct nameidata's
1) turn NDINITAT into a function and make the macros point to it with the later goal of getting rid of them. 2) Sweep the kernel for places where people make a struct nameidata manually on the stack and fill in what they hope are the required fields and count on prayer and clean living to always get them right. Instead use NDINIT everywhere. NFS was especially bad for this and there have likely been things lurking there for a while. 3) Add a couple of strategic KASSERT's to catch future offenders. ok krw@ sthen@ deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/diskmap.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/dev/diskmap.c b/sys/dev/diskmap.c
index d99591e1857..ef3e90c517d 100644
--- a/sys/dev/diskmap.c
+++ b/sys/dev/diskmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diskmap.c,v 1.14 2016/03/19 12:04:15 natano Exp $ */
+/* $OpenBSD: diskmap.c,v 1.15 2016/04/29 14:40:36 beck Exp $ */
/*
* Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org>
@@ -37,6 +37,7 @@
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/pledge.h>
+#include <sys/namei.h>
int
diskmapopen(dev_t dev, int flag, int fmt, struct proc *p)
@@ -85,10 +86,7 @@ diskmapioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
fdp = p->p_fd;
fdplock(fdp);
- ndp.ni_segflg = UIO_SYSSPACE;
- ndp.ni_dirfd = AT_FDCWD;
- ndp.ni_dirp = devname;
- ndp.ni_cnd.cn_proc = p;
+ NDINIT(&ndp, 0, 0, UIO_SYSSPACE, devname, p);
ndp.ni_pledge = PLEDGE_RPATH;
if ((error = vn_open(&ndp, fp->f_flag, 0)) != 0)
goto bad;