CVS commit: [prg-localcount2] src/sys/ufs/ext2fs

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 05:31:08 UTC 2017

Modified Files:
src/sys/ufs/ext2fs [prg-localcount2]: ext2fs_vfsops.c

Log Message:
Typo - insert missing *


To generate a diff of this commit:
cvs rdiff -u -r1.208.2.1 -r1.208.2.2 src/sys/ufs/ext2fs/ext2fs_vfsops.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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208.2.1 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208.2.2
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208.2.1	Wed May 17 04:08:36 2017
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Wed May 17 05:31:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.208.2.1 2017/05/17 04:08:36 pgoyette Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.208.2.2 2017/05/17 05:31:08 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208.2.1 2017/05/17 04:08:36 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208.2.2 2017/05/17 05:31:08 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -301,7 +301,7 @@ ext2fs_mountroot(void)
 int
 ext2fs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
 {
-	const struct bdevsw devsw;
+	const struct bdevsw *devsw;
 	struct lwp *l = curlwp;
 	struct vnode *devvp;
 	struct ufs_args *args = data;



CVS commit: [prg-localcount2] src/sys/ufs/ext2fs

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 05:31:08 UTC 2017

Modified Files:
src/sys/ufs/ext2fs [prg-localcount2]: ext2fs_vfsops.c

Log Message:
Typo - insert missing *


To generate a diff of this commit:
cvs rdiff -u -r1.208.2.1 -r1.208.2.2 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: [prg-localcount2] src/sys/kern

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:33:03 UTC 2017

Modified Files:
src/sys/kern [prg-localcount2]: subr_devsw.c

Log Message:
Allow the argument to {b,c}devsw_release() to be NULL, and treat it as
a No-Op


To generate a diff of this commit:
cvs rdiff -u -r1.37.2.3 -r1.37.2.4 src/sys/kern/subr_devsw.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/kern/subr_devsw.c
diff -u src/sys/kern/subr_devsw.c:1.37.2.3 src/sys/kern/subr_devsw.c:1.37.2.4
--- src/sys/kern/subr_devsw.c:1.37.2.3	Fri Apr 28 03:41:26 2017
+++ src/sys/kern/subr_devsw.c	Wed May 17 04:33:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_devsw.c,v 1.37.2.3 2017/04/28 03:41:26 pgoyette Exp $	*/
+/*	$NetBSD: subr_devsw.c,v 1.37.2.4 2017/05/17 04:33:03 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.37.2.3 2017/04/28 03:41:26 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.37.2.4 2017/05/17 04:33:03 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dtrace.h"
@@ -505,8 +505,7 @@ void
 bdevsw_release(const struct bdevsw *bd)
 {
 
-	KASSERT(bd != NULL);
-	if (bd->d_localcount != NULL)
+	if (bd != NULL && bd->d_localcount != NULL)
 		localcount_release(bd->d_localcount, _cv, _lock);
 }
 
@@ -569,8 +568,7 @@ void
 cdevsw_release(const struct cdevsw *cd)
 {
 
-	KASSERT(cd != NULL);
-	if (cd->d_localcount != NULL)
+	if (cd != NULL && cd->d_localcount != NULL)
 		localcount_release(cd->d_localcount, _cv, _lock);
 }
 



CVS commit: [prg-localcount2] src/sys/kern

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:33:03 UTC 2017

Modified Files:
src/sys/kern [prg-localcount2]: subr_devsw.c

Log Message:
Allow the argument to {b,c}devsw_release() to be NULL, and treat it as
a No-Op


To generate a diff of this commit:
cvs rdiff -u -r1.37.2.3 -r1.37.2.4 src/sys/kern/subr_devsw.c

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



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:29:46 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Finish previous.  :(


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.3 -r1.89.8.4 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.3 src/sys/dev/mscp/mscp_disk.c:1.89.8.4
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.3	Wed May 17 04:26:14 2017
+++ src/sys/dev/mscp/mscp_disk.c	Wed May 17 04:29:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.4 2017/05/17 04:29:46 pgoyette Exp $");
 
 #include 
 #include 
@@ -1192,23 +1192,23 @@ mscp_device_lookup(dev_t dev)
 	ra = NULL;
 #if NRA
 	if (( dev_cdevsw = cdevsw_lookup_acquire(dev)) == _cdevsw) {
-		ra = device_lookup_private(_cd, unit);
+		ra = device_lookup_private_acquire(_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	} else
 		cdevsw_release(dev_cdevsw);
 #endif
 #if NRACD
-	if ((dev_cdevsw = cdevsw_lookup(dev)) == _cdevsw) {
-		ra = device_lookup_private(_cd, unit);
+	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == _cdevsw) {
+		ra = device_lookup_private_acquire(_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	} else
 		cdevsw_release(dev_cdevsw);
 #endif
 #if NRX
-	if (cdevsw_lookup(dev) == _cdevsw)
-		ra = device_lookup_private(_cd, unit);
+	if ((dev_cdevsw = cdevsw_lookup_acquire(dev)) == _cdevsw)
+		ra = device_lookup_private_acquire(_cd, unit);
 		cdevsw_release(dev_cdevsw);
 		return ra;
 	else



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:29:46 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Finish previous.  :(


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.3 -r1.89.8.4 src/sys/dev/mscp/mscp_disk.c

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



CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:26:14 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Adapt to device_lookup_acquire


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.2 -r1.89.8.3 src/sys/dev/mscp/mscp_disk.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/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.89.8.2 src/sys/dev/mscp/mscp_disk.c:1.89.8.3
--- src/sys/dev/mscp/mscp_disk.c:1.89.8.2	Sun May 14 13:02:35 2017
+++ src/sys/dev/mscp/mscp_disk.c	Wed May 17 04:26:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $	*/
+/*	$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $	*/
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.2 2017/05/14 13:02:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.89.8.3 2017/05/17 04:26:14 pgoyette Exp $");
 
 #include 
 #include 
@@ -271,7 +271,7 @@ raopen(dev_t dev, int flag, int fmt, str
 		if ((error = tsleep((void *)ra, (PZERO + 1) | PCATCH,
 		devopn, 0))) {
 			splx(s);
-			return (error);
+			goto bad2;
 		}
 #endif
 
@@ -289,6 +289,8 @@ raopen(dev_t dev, int flag, int fmt, str
 	error = 0;
  bad1:
 	mutex_exit(>ra_disk.dk_openlock);
+ bad2:
+	device_release(ra->ra_dev);
 	return (error);
 }
 
@@ -328,6 +330,7 @@ raclose(dev_t dev, int flags, int fmt, s
 	}
 #endif
 	mutex_exit(>ra_disk.dk_openlock);
+	device_release(ra->ra_dev);
 	return (0);
 }
 
@@ -345,7 +348,7 @@ rastrategy(struct buf *bp)
 	 */
 	if (ra == NULL) {
 		bp->b_error = ENXIO;
-		goto done;
+		goto done1;
 	}
 	/*
 	 * If drive is open `raw' or reading label, let it at it.
@@ -356,6 +359,7 @@ rastrategy(struct buf *bp)
 	disk_busy(>ra_disk);
 		splx(b);
 		mscp_strategy(bp, device_parent(ra->ra_dev));
+		device_release(ra->ra_dev);
 		return;
 	}
 
@@ -378,9 +382,12 @@ rastrategy(struct buf *bp)
 	disk_busy(>ra_disk);
 	splx(b);
 	mscp_strategy(bp, device_parent(ra->ra_dev));
+	device_release(ra->ra_dev);
 	return;
 
-done:
+ done:
+	device_release(ra->ra_dev);
+ done1:
 	biodone(bp);
 }
 
@@ -414,9 +421,10 @@ raioctl(dev_t dev, u_long cmd, void *dat
 	lp = ra->ra_disk.dk_label;
 
 	error = disk_ioctl(>ra_disk, dev, cmd, data, flag, l);
-	if (error != EPASSTHROUGH)
+	if (error != EPASSTHROUGH) {
+		device_release(ra->ra_dev);
 		return error;
-	else
+	} else
 		error = 0;
 
 	switch (cmd) {
@@ -489,6 +497,7 @@ raioctl(dev_t dev, u_long cmd, void *dat
 		error = ENOTTY;
 		break;
 	}
+	device_release(ra->ra_dev);
 	return (error);
 }
 
@@ -504,17 +513,22 @@ radump(dev_t dev, daddr_t blkno, void *v
 int
 rasize(dev_t dev)
 {
+	int rv;
 	struct ra_softc *ra = mscp_device_lookup(dev);
 
 	if (!ra)
 		return -1;
 
 	if (ra->ra_state == DK_CLOSED)
-		if (ra_putonline(dev, ra) == MSCP_FAILED)
+		if (ra_putonline(dev, ra) == MSCP_FAILED) {
+			device_release(ra->ra_dev);
 			return -1;
+		}
 
-	return ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
+	rv = ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
 	(ra->ra_disk.dk_label->d_secsize / DEV_BSIZE);
+	device_release(ra->ra_dev);
+	return rv;
 }
 
 #endif /* NRA || NRACD || NRX */
@@ -1107,6 +1121,7 @@ rrfillin(struct buf *bp, struct mscp *mp
 	mp->mscp_seq.seq_lbn = lp->d_partitions[part].p_offset + bp->b_blkno;
 	mp->mscp_unit = ra->ra_hwunit;
 	mp->mscp_seq.seq_bytecount = bp->b_bcount;
+	device_release(ra->ra_dev);
 }
 
 /*
@@ -1166,37 +1181,46 @@ ra_putonline(dev_t dev, struct ra_softc 
 	return MSCP_DONE;
 }
 
-/* XXX
- *	This code needs to be restructured to deal with the localcount(9)
- *	referencing counting on {b,c}devsw.  Since we're returning the
- *	softc address here, we need to use cdevsw_lookup_acquire() to
- *	keep a reference to the device.  So all callers need to be able
- *	to determine which device's cdevsw needs to be released later on.
- * XXX
- */
 static inline struct ra_softc *
 mscp_device_lookup(dev_t dev)
 {
+	const struct dev_cdevsw;
 	struct ra_softc *ra;
 	int unit;
 
 	unit = DISKUNIT(dev);
+	ra = NULL;
 #if NRA
-	if (cdevsw_lookup(dev) == _cdevsw)
+	if (( dev_cdevsw = cdevsw_lookup_acquire(dev)) == _cdevsw) {
 		ra = device_lookup_private(_cd, unit);
-	else
+		cdevsw_release(dev_cdevsw);
+		return ra;
+	} else
+		cdevsw_release(dev_cdevsw);
 #endif
 #if NRACD
-	if (cdevsw_lookup(dev) == _cdevsw)
+	if ((dev_cdevsw = cdevsw_lookup(dev)) == _cdevsw) {
 		ra = device_lookup_private(_cd, unit);
-	else
+		cdevsw_release(dev_cdevsw);
+		return ra;
+	} else
+		cdevsw_release(dev_cdevsw);
 #endif
 #if NRX
 	if (cdevsw_lookup(dev) == _cdevsw)
 		ra = device_lookup_private(_cd, unit);
+		cdevsw_release(dev_cdevsw);
+		return ra;
 	else
+		cdevsw_release(dev_cdevsw);
 #endif
-		

CVS commit: [prg-localcount2] src/sys/dev/mscp

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:26:14 UTC 2017

Modified Files:
src/sys/dev/mscp [prg-localcount2]: mscp_disk.c

Log Message:
Adapt to device_lookup_acquire


To generate a diff of this commit:
cvs rdiff -u -r1.89.8.2 -r1.89.8.3 src/sys/dev/mscp/mscp_disk.c

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



CVS commit: [prg-localcount2] src/sys/ufs/ext2fs

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:08:36 UTC 2017

Modified Files:
src/sys/ufs/ext2fs [prg-localcount2]: ext2fs_vfsops.c

Log Message:
Adapt for bdevsw_lookup_acquire()


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.208.2.1 src/sys/ufs/ext2fs/ext2fs_vfsops.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/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208.2.1
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.208	Mon Apr 17 08:32:01 2017
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Wed May 17 04:08:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 hannken Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.208.2.1 2017/05/17 04:08:36 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208 2017/04/17 08:32:01 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.208.2.1 2017/05/17 04:08:36 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -301,6 +301,7 @@ ext2fs_mountroot(void)
 int
 ext2fs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
 {
+	const struct bdevsw devsw;
 	struct lwp *l = curlwp;
 	struct vnode *devvp;
 	struct ufs_args *args = data;
@@ -342,8 +343,13 @@ ext2fs_mount(struct mount *mp, const cha
 			 */
 			if (devvp->v_type != VBLK)
 error = ENOTBLK;
-			else if (bdevsw_lookup(devvp->v_rdev) == NULL)
-error = ENXIO;
+			else {
+devsw = bdevsw_lookup_acquire(devvp->v_rdev);
+if (devsw == NULL)
+	error = ENXIO;
+else
+	bdevsw_release(devsw);
+			}
 		} else {
 		/*
 			 * Be sure we're still naming the same device



CVS commit: [prg-localcount2] src/sys/ufs/ext2fs

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 04:08:36 UTC 2017

Modified Files:
src/sys/ufs/ext2fs [prg-localcount2]: ext2fs_vfsops.c

Log Message:
Adapt for bdevsw_lookup_acquire()


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.208.2.1 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: [prg-localcount2] src/sys/arch/mipsco/obio

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 03:54:20 UTC 2017

Modified Files:
src/sys/arch/mipsco/obio [prg-localcount2]: zs_kgdb.c

Log Message:
Convert to cdevsw_lookup_acquire()


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.54.1 src/sys/arch/mipsco/obio/zs_kgdb.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/arch/mipsco/obio/zs_kgdb.c
diff -u src/sys/arch/mipsco/obio/zs_kgdb.c:1.10 src/sys/arch/mipsco/obio/zs_kgdb.c:1.10.54.1
--- src/sys/arch/mipsco/obio/zs_kgdb.c:1.10	Wed Mar 18 10:22:32 2009
+++ src/sys/arch/mipsco/obio/zs_kgdb.c	Wed May 17 03:54:20 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs_kgdb.c,v 1.10 2009/03/18 10:22:32 cegger Exp $	*/
+/*	$NetBSD: zs_kgdb.c,v 1.10.54.1 2017/05/17 03:54:20 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs_kgdb.c,v 1.10 2009/03/18 10:22:32 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs_kgdb.c,v 1.10.54.1 2017/05/17 03:54:20 pgoyette Exp $");
 
 #include 
 #include 
@@ -129,10 +129,13 @@ zs_kgdb_init(void)
 {
 	struct zschan *zc;
 	int channel, unit;
+	const struct cdevsw kgbd_cdevsw;
 	extern const struct cdevsw zstty_cdevsw;
 
-	if (cdevsw_lookup(kgdb_dev) != _cdevsw)
+	if ((kgdb_cdevsw = cdevsw_lookup_acquire(kgdb_dev)) != _cdevsw) {
+		cdevsw_release(kgdb_cdevsw);
 		return;
+	}
 
 	unit = (kgdb_dev & 2) ? 2 : 0;
 	channel = kgdb_dev & 1;



CVS commit: [prg-localcount2] src/sys/arch/mipsco/obio

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 03:54:20 UTC 2017

Modified Files:
src/sys/arch/mipsco/obio [prg-localcount2]: zs_kgdb.c

Log Message:
Convert to cdevsw_lookup_acquire()


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.54.1 src/sys/arch/mipsco/obio/zs_kgdb.c

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



CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 03:05:44 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
It's "device_t x" not "struct device_t x"


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.2 -r1.39.6.3 src/sys/dev/ata/ata_raid.c

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



CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 03:05:44 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
It's "device_t x" not "struct device_t x"


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.2 -r1.39.6.3 src/sys/dev/ata/ata_raid.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/ata/ata_raid.c
diff -u src/sys/dev/ata/ata_raid.c:1.39.6.2 src/sys/dev/ata/ata_raid.c:1.39.6.3
--- src/sys/dev/ata/ata_raid.c:1.39.6.2	Wed May 17 02:58:37 2017
+++ src/sys/dev/ata/ata_raid.c	Wed May 17 03:05:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $	*/
+/*	$NetBSD: ata_raid.c,v 1.39.6.3 2017/05/17 03:05:44 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.3 2017/05/17 03:05:44 pgoyette Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ ata_raid_type_name(u_int type)
 static int
 ata_raid_finalize(device_t self)
 {
-	struct device_t dev;
+	device_t dev;
 	static struct cfdata ataraid_cfdata = {
 		.cf_name = "ataraid",
 		.cf_atname = "ataraid",



CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:58:37 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.1 -r1.39.6.2 src/sys/dev/ata/ata_raid.c

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



CVS commit: [prg-localcount2] src/sys/dev/ata

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:58:37 UTC 2017

Modified Files:
src/sys/dev/ata [prg-localcount2]: ata_raid.c

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.39.6.1 -r1.39.6.2 src/sys/dev/ata/ata_raid.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/ata/ata_raid.c
diff -u src/sys/dev/ata/ata_raid.c:1.39.6.1 src/sys/dev/ata/ata_raid.c:1.39.6.2
--- src/sys/dev/ata/ata_raid.c:1.39.6.1	Wed May 17 01:44:17 2017
+++ src/sys/dev/ata/ata_raid.c	Wed May 17 02:58:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $	*/
+/*	$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.2 2017/05/17 02:58:37 pgoyette Exp $");
 
 #include 
 #include 
@@ -155,7 +155,7 @@ ata_raid_type_name(u_int type)
 static int
 ata_raid_finalize(device_t self)
 {
-	stgruct device_t dev;
+	struct device_t dev;
 	static struct cfdata ataraid_cfdata = {
 		.cf_name = "ataraid",
 		.cf_atname = "ataraid",



CVS commit: [prg-localcount2] src/sys/net

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:40:58 UTC 2017

Modified Files:
src/sys/net [prg-localcount2]: if_tap.c

Log Message:
Actually return the retrun value that we computed.


To generate a diff of this commit:
cvs rdiff -u -r1.99.4.2 -r1.99.4.3 src/sys/net/if_tap.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/net/if_tap.c
diff -u src/sys/net/if_tap.c:1.99.4.2 src/sys/net/if_tap.c:1.99.4.3
--- src/sys/net/if_tap.c:1.99.4.2	Wed May 17 01:44:18 2017
+++ src/sys/net/if_tap.c	Wed May 17 02:40:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tap.c,v 1.99.4.2 2017/05/17 01:44:18 pgoyette Exp $	*/
+/*	$NetBSD: if_tap.c,v 1.99.4.3 2017/05/17 02:40:58 pgoyette Exp $	*/
 
 /*
  *  Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.99.4.2 2017/05/17 01:44:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.99.4.3 2017/05/17 02:40:58 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 
@@ -808,6 +808,7 @@ tap_dev_cloner(struct lwp *l)
 	(void *)(intptr_t)device_unit(sc->sc_dev));
 
 	device_release(sc->sc_dev);
+	return rv;
 }
 
 /*



CVS commit: [prg-localcount2] src/sys/net

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:40:58 UTC 2017

Modified Files:
src/sys/net [prg-localcount2]: if_tap.c

Log Message:
Actually return the retrun value that we computed.


To generate a diff of this commit:
cvs rdiff -u -r1.99.4.2 -r1.99.4.3 src/sys/net/if_tap.c

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



CVS commit: [prg-localcount2] src/sys/dev/sysmon

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:37:02 UTC 2017

Modified Files:
src/sys/dev/sysmon [prg-localcount2]: swwdog.c

Log Message:
Use correct variable name


To generate a diff of this commit:
cvs rdiff -u -r1.19.8.1 -r1.19.8.2 src/sys/dev/sysmon/swwdog.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/sysmon/swwdog.c
diff -u src/sys/dev/sysmon/swwdog.c:1.19.8.1 src/sys/dev/sysmon/swwdog.c:1.19.8.2
--- src/sys/dev/sysmon/swwdog.c:1.19.8.1	Wed May 17 01:44:18 2017
+++ src/sys/dev/sysmon/swwdog.c	Wed May 17 02:37:02 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $	*/
+/*	$NetBSD: swwdog.c,v 1.19.8.2 2017/05/17 02:37:02 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2004, 2005 Steven M. Bellovin
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19.8.2 2017/05/17 02:37:02 pgoyette Exp $");
 
 /*
  *
@@ -145,7 +145,7 @@ swwdogattach(int n __unused)
 		workqueue_destroy(wq);
 		return 1;
 	}
-	device_release(dev);
+	device_release(swwdog_dev);
 	return 0;
 }
 



CVS commit: [prg-localcount2] src/sys/dev/sysmon

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 02:37:02 UTC 2017

Modified Files:
src/sys/dev/sysmon [prg-localcount2]: swwdog.c

Log Message:
Use correct variable name


To generate a diff of this commit:
cvs rdiff -u -r1.19.8.1 -r1.19.8.2 src/sys/dev/sysmon/swwdog.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed May 17 02:19:10 UTC 2017

Modified Files:
src/sys/netipsec: key.c keydb.h

Log Message:
Replace malloc/free with kmem(9) and kill KMALLOC/KFREE macros


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/netipsec/key.c
cvs rdiff -u -r1.14 -r1.15 src/sys/netipsec/keydb.h

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

Modified files:

Index: src/sys/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.131 src/sys/netipsec/key.c:1.132
--- src/sys/netipsec/key.c:1.131	Wed May 17 02:04:55 2017
+++ src/sys/netipsec/key.c	Wed May 17 02:19:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.131 2017/05/17 02:04:55 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.132 2017/05/17 02:19:09 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.131 2017/05/17 02:04:55 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.132 2017/05/17 02:19:09 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -52,7 +52,6 @@ __KERNEL_RCSID(0, "$NetBSD: key.c,v 1.13
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -333,26 +332,6 @@ do { \
 
 MALLOC_DEFINE(M_SECA, "key mgmt", "security associations, key management");
 
-#if 1
-#define KMALLOC(p, t, n) \
-	((p) = (t) malloc((unsigned long)(n), M_SECA, M_NOWAIT))
-#define KFREE(p) \
-	free((p), M_SECA)
-#else
-#define KMALLOC(p, t, n) \
-do { \
-	((p) = malloc((unsigned long)(n), M_SECA, M_NOWAIT)); \
-	printf("%s %d: %p <- KMALLOC(%s, %d)\n", \
-	__func__, __LINE__, (p), #t, n); 	\
-} while (0)
-
-#define KFREE(p) \
-	do { \
-		printf("%s %d: %p -> KFREE()\n", __func__, __LINE__, (p));   \
-		free((p), M_SECA);  \
-	} while (0)
-#endif
-
 /*
  * set parameters into secpolicyindex buffer.
  * Must allocate secpolicyindex buffer passed to this function.
@@ -2930,9 +2909,9 @@ key_delsah(struct secashead *sah)
 		LIST_REMOVE(sah, chain);
 
 	if (sah->idents != NULL)
-		KFREE(sah->idents);
+		kmem_free(sah->idents, sah->idents_len);
 	if (sah->identd != NULL)
-		KFREE(sah->identd);
+		kmem_free(sah->identd, sah->identd_len);
 
 	kmem_free(sah, sizeof(*sah));
 
@@ -3157,27 +3136,30 @@ key_freesaval(struct secasvar *sav)
 {
 
 	if (sav->replay != NULL) {
-		KFREE(sav->replay);
+		kmem_free(sav->replay, sav->replay_len);
 		sav->replay = NULL;
+		sav->replay_len = 0;
 	}
 	if (sav->key_auth != NULL) {
-		KFREE(sav->key_auth);
+		kmem_free(sav->key_auth, sav->key_auth_len);
 		sav->key_auth = NULL;
+		sav->key_auth_len = 0;
 	}
 	if (sav->key_enc != NULL) {
-		KFREE(sav->key_enc);
+		kmem_free(sav->key_enc, sav->key_enc_len);
 		sav->key_enc = NULL;
+		sav->key_enc_len = 0;
 	}
 	if (sav->lft_c != NULL) {
 		kmem_free(sav->lft_c, sizeof(*(sav->lft_c)));
 		sav->lft_c = NULL;
 	}
 	if (sav->lft_h != NULL) {
-		KFREE(sav->lft_h);
+		kmem_free(sav->lft_h, sizeof(*(sav->lft_h)));
 		sav->lft_h = NULL;
 	}
 	if (sav->lft_s != NULL) {
-		KFREE(sav->lft_s);
+		kmem_free(sav->lft_s, sizeof(*(sav->lft_s)));
 		sav->lft_s = NULL;
 	}
 }
@@ -3226,13 +3208,10 @@ key_setsaval(struct secasvar *sav, struc
 
 		/* replay window */
 		if ((sa0->sadb_sa_flags & SADB_X_EXT_OLD) == 0) {
-			sav->replay = (struct secreplay *)
-malloc(sizeof(struct secreplay)+sa0->sadb_sa_replay, M_SECA, M_NOWAIT|M_ZERO);
-			if (sav->replay == NULL) {
-ipseclog((LOG_DEBUG, "key_setsaval: No more memory.\n"));
-error = ENOBUFS;
-goto fail;
-			}
+			size_t len = sizeof(struct secreplay) +
+			sa0->sadb_sa_replay;
+			sav->replay = kmem_zalloc(len, KM_SLEEP);
+			sav->replay_len = len;
 			if (sa0->sadb_sa_replay != 0)
 sav->replay->bitmap = (char*)(sav->replay+1);
 			sav->replay->wsize = sa0->sadb_sa_replay;
@@ -3270,12 +3249,8 @@ key_setsaval(struct secasvar *sav, struc
 			goto fail;
 		}
 
-		sav->key_auth = (struct sadb_key *)key_newbuf(key0, len);
-		if (sav->key_auth == NULL) {
-			ipseclog((LOG_DEBUG, "key_setsaval: No more memory.\n"));
-			error = ENOBUFS;
-			goto fail;
-		}
+		sav->key_auth = key_newbuf(key0, len);
+		sav->key_auth_len = len;
 	}
 
 	/* Encryption key */
@@ -3298,12 +3273,8 @@ key_setsaval(struct secasvar *sav, struc
 error = EINVAL;
 break;
 			}
-			sav->key_enc = (struct sadb_key *)key_newbuf(key0, len);
-			if (sav->key_enc == NULL) {
-ipseclog((LOG_DEBUG, "key_setsaval: No more memory.\n"));
-error = ENOBUFS;
-goto fail;
-			}
+			sav->key_enc = key_newbuf(key0, 

CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed May 17 02:19:10 UTC 2017

Modified Files:
src/sys/netipsec: key.c keydb.h

Log Message:
Replace malloc/free with kmem(9) and kill KMALLOC/KFREE macros


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/netipsec/key.c
cvs rdiff -u -r1.14 -r1.15 src/sys/netipsec/keydb.h

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed May 17 02:04:56 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Fix memory leaks of allocated data to sav on key_update

key_setsaval NULL-clears member variables of sav at the beginning
of the function regardless of the states of the variables. When
key_setsaval is called by key_update, member variables sav->replay,
sav->key_* and sav->lft_* may have data allocated by malloc. In
that case they will leak. Free them before NULL-clear to avoid
memory leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/netipsec/key.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed May 17 02:04:56 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Fix memory leaks of allocated data to sav on key_update

key_setsaval NULL-clears member variables of sav at the beginning
of the function regardless of the states of the variables. When
key_setsaval is called by key_update, member variables sav->replay,
sav->key_* and sav->lft_* may have data allocated by malloc. In
that case they will leak. Free them before NULL-clear to avoid
memory leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.130 src/sys/netipsec/key.c:1.131
--- src/sys/netipsec/key.c:1.130	Tue May 16 10:11:24 2017
+++ src/sys/netipsec/key.c	Wed May 17 02:04:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.130 2017/05/16 10:11:24 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.131 2017/05/17 02:04:55 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.130 2017/05/16 10:11:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.131 2017/05/17 02:04:55 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -431,6 +431,7 @@ static struct secasvar *key_checkspidup 
 static struct secasvar *key_getsavbyspi (struct secashead *, u_int32_t);
 static int key_setsaval (struct secasvar *, struct mbuf *,
 	const struct sadb_msghdr *);
+static void key_freesaval(struct secasvar *);
 static int key_mature (struct secasvar *);
 static struct mbuf *key_setdumpsa (struct secasvar *, u_int8_t,
 	u_int8_t, u_int32_t, u_int32_t);
@@ -3056,31 +3057,8 @@ key_delsav(struct secasvar *sav)
 			explicit_memset(_KEYBUF(sav->key_enc), 0,
 			_KEYLEN(sav->key_enc));
 	}
-	if (sav->key_auth != NULL) {
-		KFREE(sav->key_auth);
-		sav->key_auth = NULL;
-	}
-	if (sav->key_enc != NULL) {
-		KFREE(sav->key_enc);
-		sav->key_enc = NULL;
-	}
-	if (sav->replay != NULL) {
-		KFREE(sav->replay);
-		sav->replay = NULL;
-	}
-	if (sav->lft_c != NULL) {
-		kmem_intr_free(sav->lft_c, sizeof(*(sav->lft_c)));
-		sav->lft_c = NULL;
-	}
-	if (sav->lft_h != NULL) {
-		KFREE(sav->lft_h);
-		sav->lft_h = NULL;
-	}
-	if (sav->lft_s != NULL) {
-		KFREE(sav->lft_s);
-		sav->lft_s = NULL;
-	}
 
+	key_freesaval(sav);
 	kmem_intr_free(sav, sizeof(*sav));
 
 	return;
@@ -3171,6 +3149,40 @@ key_getsavbyspi(struct secashead *sah, u
 }
 
 /*
+ * Free allocated data to member variables of sav:
+ * sav->replay, sav->key_* and sav->lft_*.
+ */
+static void
+key_freesaval(struct secasvar *sav)
+{
+
+	if (sav->replay != NULL) {
+		KFREE(sav->replay);
+		sav->replay = NULL;
+	}
+	if (sav->key_auth != NULL) {
+		KFREE(sav->key_auth);
+		sav->key_auth = NULL;
+	}
+	if (sav->key_enc != NULL) {
+		KFREE(sav->key_enc);
+		sav->key_enc = NULL;
+	}
+	if (sav->lft_c != NULL) {
+		kmem_free(sav->lft_c, sizeof(*(sav->lft_c)));
+		sav->lft_c = NULL;
+	}
+	if (sav->lft_h != NULL) {
+		KFREE(sav->lft_h);
+		sav->lft_h = NULL;
+	}
+	if (sav->lft_s != NULL) {
+		KFREE(sav->lft_s);
+		sav->lft_s = NULL;
+	}
+}
+
+/*
  * copy SA values from PF_KEY message except *SPI, SEQ, PID, STATE and TYPE*.
  * You must update these if need.
  * OUT:	0:	success.
@@ -3190,12 +3202,7 @@ key_setsaval(struct secasvar *sav, struc
 	KASSERT(mhp->msg != NULL);
 
 	/* initialization */
-	sav->replay = NULL;
-	sav->key_auth = NULL;
-	sav->key_enc = NULL;
-	sav->lft_c = NULL;
-	sav->lft_h = NULL;
-	sav->lft_s = NULL;
+	key_freesaval(sav);
 	sav->tdb_xform = NULL;		/* transform */
 	sav->tdb_encalgxform = NULL;	/* encoding algorithm */
 	sav->tdb_authalgxform = NULL;	/* authentication algorithm */
@@ -3394,30 +3401,7 @@ key_setsaval(struct secasvar *sav, struc
 
  fail:
 	/* initialization */
-	if (sav->replay != NULL) {
-		KFREE(sav->replay);
-		sav->replay = NULL;
-	}
-	if (sav->key_auth != NULL) {
-		KFREE(sav->key_auth);
-		sav->key_auth = NULL;
-	}
-	if (sav->key_enc != NULL) {
-		KFREE(sav->key_enc);
-		sav->key_enc = NULL;
-	}
-	if (sav->lft_c != NULL) {
-		kmem_free(sav->lft_c, sizeof(*(sav->lft_c)));
-		sav->lft_c = NULL;
-	}
-	if (sav->lft_h != NULL) {
-		KFREE(sav->lft_h);
-		sav->lft_h = NULL;
-	}
-	if (sav->lft_s != NULL) {
-		KFREE(sav->lft_s);
-		sav->lft_s = NULL;
-	}
+	key_freesaval(sav);
 
 	return error;
 }



CVS commit: [prg-localcount2] src/share/man/man9

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:54:06 UTC 2017

Modified Files:
src/share/man/man9 [prg-localcount2]: autoconf.9

Log Message:
Update autoconf(9) to mention that config_attach_pseudo() returns with
a reference held on the device.


To generate a diff of this commit:
cvs rdiff -u -r1.30.20.1 -r1.30.20.2 src/share/man/man9/autoconf.9

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

Modified files:

Index: src/share/man/man9/autoconf.9
diff -u src/share/man/man9/autoconf.9:1.30.20.1 src/share/man/man9/autoconf.9:1.30.20.2
--- src/share/man/man9/autoconf.9:1.30.20.1	Fri Apr 28 06:00:33 2017
+++ src/share/man/man9/autoconf.9	Wed May 17 01:54:06 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: autoconf.9,v 1.30.20.1 2017/04/28 06:00:33 pgoyette Exp $
+.\" $NetBSD: autoconf.9,v 1.30.20.2 2017/05/17 01:54:06 pgoyette Exp $
 .\"
 .\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -342,6 +342,12 @@ object and pass it to
 The content of that object is similar to what is returned by
 .Fn config_search_loc
 for regular devices.
+.Pp
+.Fn config_attach_pseudo
+acquires a reference to the returned device_t (via
+.Fn device_acquire ) ;
+the caller is responsible for releasing the reference via
+.Fn device_release .
 .It Fn config_detach "dev" "flags"
 .It Fn config_detach_release "dev" "flags"
 Called by the parent to acquire a reference to and detach the child device.



CVS commit: [prg-localcount2] src/share/man/man9

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:54:06 UTC 2017

Modified Files:
src/share/man/man9 [prg-localcount2]: autoconf.9

Log Message:
Update autoconf(9) to mention that config_attach_pseudo() returns with
a reference held on the device.


To generate a diff of this commit:
cvs rdiff -u -r1.30.20.1 -r1.30.20.2 src/share/man/man9/autoconf.9

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



CVS commit: [prg-localcount2] src/sys

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:44:18 UTC 2017

Modified Files:
src/sys/arch/atari/atari [prg-localcount2]: autoconf.c
src/sys/dev [prg-localcount2]: cgd.c fss.c md.c vnd.c
src/sys/dev/ata [prg-localcount2]: ata_raid.c
src/sys/dev/bluetooth [prg-localcount2]: bcsp.c btuart.c
src/sys/dev/dkwedge [prg-localcount2]: dk.c
src/sys/dev/dm [prg-localcount2]: dm_ioctl.c
src/sys/dev/gpio [prg-localcount2]: gpiosim.c
src/sys/dev/hpc [prg-localcount2]: hpf1275a_tty.c
src/sys/dev/ir [prg-localcount2]: irframe_tty.c
src/sys/dev/iscsi [prg-localcount2]: iscsi_main.c
src/sys/dev/nand [prg-localcount2]: nandemulator.c
src/sys/dev/pad [prg-localcount2]: pad.c
src/sys/dev/raidframe [prg-localcount2]: rf_netbsdkintf.c
src/sys/dev/sysmon [prg-localcount2]: swwdog.c
src/sys/kern [prg-localcount2]: subr_autoconf.c
src/sys/modules/lua [prg-localcount2]: lua.c
src/sys/net [prg-localcount2]: if_etherip.c if_tap.c
src/sys/opencrypto [prg-localcount2]: cryptodev.c cryptosoft.c

Log Message:
At suggestion of chuq@, modify config_attach_pseudo() to return with a
reference held on the device.

Adapt callers to expect the reference to exist, and to ensure that the
reference is released.


To generate a diff of this commit:
cvs rdiff -u -r1.65.20.1 -r1.65.20.2 src/sys/arch/atari/atari/autoconf.c
cvs rdiff -u -r1.114.4.6 -r1.114.4.7 src/sys/dev/cgd.c
cvs rdiff -u -r1.97.4.3 -r1.97.4.4 src/sys/dev/fss.c
cvs rdiff -u -r1.78.6.5 -r1.78.6.6 src/sys/dev/md.c
cvs rdiff -u -r1.259.4.4 -r1.259.4.5 src/sys/dev/vnd.c
cvs rdiff -u -r1.39 -r1.39.6.1 src/sys/dev/ata/ata_raid.c
cvs rdiff -u -r1.30 -r1.30.6.1 src/sys/dev/bluetooth/bcsp.c
cvs rdiff -u -r1.28 -r1.28.8.1 src/sys/dev/bluetooth/btuart.c
cvs rdiff -u -r1.96.4.1 -r1.96.4.2 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.30 -r1.30.8.1 src/sys/dev/dm/dm_ioctl.c
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/dev/gpio/gpiosim.c
cvs rdiff -u -r1.27 -r1.27.24.1 src/sys/dev/hpc/hpf1275a_tty.c
cvs rdiff -u -r1.61.8.1 -r1.61.8.2 src/sys/dev/ir/irframe_tty.c
cvs rdiff -u -r1.24 -r1.24.6.1 src/sys/dev/iscsi/iscsi_main.c
cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/nand/nandemulator.c
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 src/sys/dev/pad/pad.c
cvs rdiff -u -r1.349.4.2 -r1.349.4.3 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.19 -r1.19.8.1 src/sys/dev/sysmon/swwdog.c
cvs rdiff -u -r1.252.4.3 -r1.252.4.4 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.20.2.2 -r1.20.2.3 src/sys/modules/lua/lua.c
cvs rdiff -u -r1.38 -r1.38.8.1 src/sys/net/if_etherip.c
cvs rdiff -u -r1.99.4.1 -r1.99.4.2 src/sys/net/if_tap.c
cvs rdiff -u -r1.89.2.2 -r1.89.2.3 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.49 -r1.49.2.1 src/sys/opencrypto/cryptosoft.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/arch/atari/atari/autoconf.c
diff -u src/sys/arch/atari/atari/autoconf.c:1.65.20.1 src/sys/arch/atari/atari/autoconf.c:1.65.20.2
--- src/sys/arch/atari/atari/autoconf.c:1.65.20.1	Thu Apr 27 05:36:32 2017
+++ src/sys/arch/atari/atari/autoconf.c	Wed May 17 01:44:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.65.20.1 2017/04/27 05:36:32 pgoyette Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.65.20.2 2017/05/17 01:44:16 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.65.20.1 2017/04/27 05:36:32 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.65.20.2 2017/05/17 01:44:16 pgoyette Exp $");
 
 #include "opt_md.h"
 
@@ -82,6 +82,7 @@ cpu_configure(void)
 void
 cpu_rootconf(void)
 {
+	device_t root;
 
 	findroot();
 #if defined(MEMORY_DISK_HOOKS)
@@ -110,7 +111,9 @@ cpu_rootconf(void)
 cf->cf_unit = i;
 cf->cf_fstate = FSTATE_STAR;
 /* XXX mutex */
-sc = device_private(config_attach_pseudo(cf));
+root = config_attach_pseudo(cf));
+sc = device_private(root);
+device_release(root);
 if (sc == NULL)
 	break;	/* XXX */
 			}

Index: src/sys/dev/cgd.c
diff -u src/sys/dev/cgd.c:1.114.4.6 src/sys/dev/cgd.c:1.114.4.7
--- src/sys/dev/cgd.c:1.114.4.6	Sat Apr 29 10:50:46 2017
+++ src/sys/dev/cgd.c	Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.114.4.6 2017/04/29 10:50:46 pgoyette Exp $ */
+/* $NetBSD: cgd.c,v 1.114.4.7 2017/05/17 01:44:17 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.6 2017/04/29 10:50:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.114.4.7 2017/05/17 01:44:17 pgoyette Exp $");
 
 #include 
 #include 
@@ -382,10 +382,7 @@ cgd_spawn(int unit, device_t *self)
 	cf->cf_unit = unit;
 	cf->cf_fstate = FSTATE_STAR;
 
-	if (config_attach_pseudo(cf) == NULL)
-		return NULL;
-
-	if ((*self = 

CVS commit: [prg-localcount2] src/sys

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:44:18 UTC 2017

Modified Files:
src/sys/arch/atari/atari [prg-localcount2]: autoconf.c
src/sys/dev [prg-localcount2]: cgd.c fss.c md.c vnd.c
src/sys/dev/ata [prg-localcount2]: ata_raid.c
src/sys/dev/bluetooth [prg-localcount2]: bcsp.c btuart.c
src/sys/dev/dkwedge [prg-localcount2]: dk.c
src/sys/dev/dm [prg-localcount2]: dm_ioctl.c
src/sys/dev/gpio [prg-localcount2]: gpiosim.c
src/sys/dev/hpc [prg-localcount2]: hpf1275a_tty.c
src/sys/dev/ir [prg-localcount2]: irframe_tty.c
src/sys/dev/iscsi [prg-localcount2]: iscsi_main.c
src/sys/dev/nand [prg-localcount2]: nandemulator.c
src/sys/dev/pad [prg-localcount2]: pad.c
src/sys/dev/raidframe [prg-localcount2]: rf_netbsdkintf.c
src/sys/dev/sysmon [prg-localcount2]: swwdog.c
src/sys/kern [prg-localcount2]: subr_autoconf.c
src/sys/modules/lua [prg-localcount2]: lua.c
src/sys/net [prg-localcount2]: if_etherip.c if_tap.c
src/sys/opencrypto [prg-localcount2]: cryptodev.c cryptosoft.c

Log Message:
At suggestion of chuq@, modify config_attach_pseudo() to return with a
reference held on the device.

Adapt callers to expect the reference to exist, and to ensure that the
reference is released.


To generate a diff of this commit:
cvs rdiff -u -r1.65.20.1 -r1.65.20.2 src/sys/arch/atari/atari/autoconf.c
cvs rdiff -u -r1.114.4.6 -r1.114.4.7 src/sys/dev/cgd.c
cvs rdiff -u -r1.97.4.3 -r1.97.4.4 src/sys/dev/fss.c
cvs rdiff -u -r1.78.6.5 -r1.78.6.6 src/sys/dev/md.c
cvs rdiff -u -r1.259.4.4 -r1.259.4.5 src/sys/dev/vnd.c
cvs rdiff -u -r1.39 -r1.39.6.1 src/sys/dev/ata/ata_raid.c
cvs rdiff -u -r1.30 -r1.30.6.1 src/sys/dev/bluetooth/bcsp.c
cvs rdiff -u -r1.28 -r1.28.8.1 src/sys/dev/bluetooth/btuart.c
cvs rdiff -u -r1.96.4.1 -r1.96.4.2 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.30 -r1.30.8.1 src/sys/dev/dm/dm_ioctl.c
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/dev/gpio/gpiosim.c
cvs rdiff -u -r1.27 -r1.27.24.1 src/sys/dev/hpc/hpf1275a_tty.c
cvs rdiff -u -r1.61.8.1 -r1.61.8.2 src/sys/dev/ir/irframe_tty.c
cvs rdiff -u -r1.24 -r1.24.6.1 src/sys/dev/iscsi/iscsi_main.c
cvs rdiff -u -r1.7 -r1.7.8.1 src/sys/dev/nand/nandemulator.c
cvs rdiff -u -r1.28.4.2 -r1.28.4.3 src/sys/dev/pad/pad.c
cvs rdiff -u -r1.349.4.2 -r1.349.4.3 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.19 -r1.19.8.1 src/sys/dev/sysmon/swwdog.c
cvs rdiff -u -r1.252.4.3 -r1.252.4.4 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.20.2.2 -r1.20.2.3 src/sys/modules/lua/lua.c
cvs rdiff -u -r1.38 -r1.38.8.1 src/sys/net/if_etherip.c
cvs rdiff -u -r1.99.4.1 -r1.99.4.2 src/sys/net/if_tap.c
cvs rdiff -u -r1.89.2.2 -r1.89.2.3 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.49 -r1.49.2.1 src/sys/opencrypto/cryptosoft.c

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



CVS commit: [prg-localcount2] src/sys/kern

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:42:17 UTC 2017

Modified Files:
src/sys/kern [prg-localcount2]: kern_event.c

Log Message:
Import fix from HEAD for NULL deref


To generate a diff of this commit:
cvs rdiff -u -r1.88.8.2 -r1.88.8.3 src/sys/kern/kern_event.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/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.88.8.2 src/sys/kern/kern_event.c:1.88.8.3
--- src/sys/kern/kern_event.c:1.88.8.2	Thu May 11 02:58:40 2017
+++ src/sys/kern/kern_event.c	Wed May 17 01:42:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.88.8.2 2017/05/11 02:58:40 pgoyette Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.88.8.3 2017/05/17 01:42:17 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.88.8.2 2017/05/11 02:58:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.88.8.3 2017/05/17 01:42:17 pgoyette Exp $");
 
 #include 
 #include 
@@ -1020,9 +1020,10 @@ kqueue_register(struct kqueue *kq, struc
 			KERNEL_UNLOCK_ONE(NULL);	/* XXXSMP */
 			if (error != 0) {
 #ifdef DIAGNOSTIC
+
 printf("%s: event not supported for file type"
-" %d (error %d)\n", __func__,
-((file_t *)kn->kn_obj)->f_type, error);
+" %d (error %d)\n", __func__, kn->kn_obj ?
+((file_t *)kn->kn_obj)->f_type : -1, error);
 #endif
 /* knote_detach() drops fdp->fd_lock */
 knote_detach(kn, fdp, false);



CVS commit: [prg-localcount2] src/sys/kern

2017-05-16 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed May 17 01:42:17 UTC 2017

Modified Files:
src/sys/kern [prg-localcount2]: kern_event.c

Log Message:
Import fix from HEAD for NULL deref


To generate a diff of this commit:
cvs rdiff -u -r1.88.8.2 -r1.88.8.3 src/sys/kern/kern_event.c

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



CVS commit: src/sys/dev

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 23:55:53 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Set sc_[trigger/rec]_started before the call to trigger_[input/output].
This prevents multiple calls to trigger_[input/output] for those drivers
that drop sc_intr_lock in there trigger_[input/output] functions.


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 src/sys/dev/audio.c

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



CVS commit: src/sys/dev

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 23:55:53 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Set sc_[trigger/rec]_started before the call to trigger_[input/output].
This prevents multiple calls to trigger_[input/output] for those drivers
that drop sc_intr_lock in there trigger_[input/output] functions.


To generate a diff of this commit:
cvs rdiff -u -r1.350 -r1.351 src/sys/dev/audio.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/audio.c
diff -u src/sys/dev/audio.c:1.350 src/sys/dev/audio.c:1.351
--- src/sys/dev/audio.c:1.350	Tue May 16 21:43:18 2017
+++ src/sys/dev/audio.c	Tue May 16 23:55:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.350 2017/05/16 21:43:18 nat Exp $	*/
+/*	$NetBSD: audio.c,v 1.351 2017/05/16 23:55:53 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.350 2017/05/16 21:43:18 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.351 2017/05/16 23:55:53 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -5470,11 +5470,13 @@ mix_read(void *arg)
 
 	if (sc->hw_if->trigger_input && sc->sc_rec_started == false) {
 		DPRINTF(("%s: call trigger_input\n", __func__));
+		sc->sc_rec_started = true;
 		error = sc->hw_if->trigger_input(sc->hw_hdl, vc->sc_mrr.s.start,
 		vc->sc_mrr.s.end, blksize,
 		audio_rint, (void *)sc, >sc_mrr.s.param);
 	} else if (sc->hw_if->start_input) {
 		DPRINTF(("%s: call start_input\n", __func__));
+		sc->sc_rec_started = true;
 		error = sc->hw_if->start_input(sc->hw_hdl,
 		vc->sc_mrr.s.inp, blksize,
 		audio_rint, (void *)sc);
@@ -5483,8 +5485,8 @@ mix_read(void *arg)
 		/* XXX does this really help? */
 		DPRINTF(("audio_upmix restart failed: %d\n", error));
 		audio_clear(sc, SIMPLEQ_FIRST(>sc_audiochan)->vc);
+		sc->sc_rec_started = false;
 	}
-	sc->sc_rec_started = true;
 
 	inp = vc->sc_mrr.s.inp;
 	vc->sc_mrr.s.inp = audio_stream_add_inp(>sc_mrr.s, inp, cc);
@@ -5575,16 +5577,17 @@ done:
 
 	if (sc->hw_if->trigger_output && sc->sc_trigger_started == false) {
 		DPRINTF(("%s: call trigger_output\n", __func__));
+		sc->sc_trigger_started = true;
 		error = sc->hw_if->trigger_output(sc->hw_hdl,
 		vc->sc_mpr.s.start, vc->sc_mpr.s.end, blksize,
 		audio_pint, (void *)sc, >sc_mpr.s.param);
 	} else if (sc->hw_if->start_output) {
 		DPRINTF(("%s: call start_output\n", __func__));
+		sc->sc_trigger_started = true;
 		error = sc->hw_if->start_output(sc->hw_hdl,
 		__UNCONST(vc->sc_mpr.s.outp), blksize,
 		audio_pint, (void *)sc);
 	}
-	sc->sc_trigger_started = true;
 
 	if (error) {
 		/* XXX does this really help? */



CVS commit: src/sys/dev/usb

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 23:49:44 UTC 2017

Modified Files:
src/sys/dev/usb: uaudio.c

Log Message:
Drop sc_lock whilst doing uaudio_chan_open uaudio[pr]transfer.
uaudio now works again.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/dev/usb/uaudio.c

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



CVS commit: src/sys/dev/usb

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 23:49:44 UTC 2017

Modified Files:
src/sys/dev/usb: uaudio.c

Log Message:
Drop sc_lock whilst doing uaudio_chan_open uaudio[pr]transfer.
uaudio now works again.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/dev/usb/uaudio.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/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.147 src/sys/dev/usb/uaudio.c:1.148
--- src/sys/dev/usb/uaudio.c:1.147	Thu Jul  7 06:55:42 2016
+++ src/sys/dev/usb/uaudio.c	Tue May 16 23:49:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.147 2016/07/07 06:55:42 msaitoh Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.148 2017/05/16 23:49:43 nat Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.147 2016/07/07 06:55:42 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.148 2017/05/16 23:49:43 nat Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2600,6 +2600,7 @@ uaudio_trigger_input(void *addr, void *s
 		ch->fraction);
 
 	mutex_exit(>sc_intr_lock);
+	mutex_exit(>sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
 		mutex_enter(>sc_intr_lock);
@@ -2622,6 +2623,7 @@ uaudio_trigger_input(void *addr, void *s
 		uaudio_chan_rtransfer(ch);
 	}
 
+	mutex_enter(>sc_lock);
 	mutex_enter(>sc_intr_lock);
 
 	return 0;
@@ -2650,6 +2652,7 @@ uaudio_trigger_output(void *addr, void *
 		ch->fraction);
 
 	mutex_exit(>sc_intr_lock);
+	mutex_exit(>sc_lock);
 	err = uaudio_chan_open(sc, ch);
 	if (err) {
 		mutex_enter(>sc_intr_lock);
@@ -2669,6 +2672,7 @@ uaudio_trigger_output(void *addr, void *
 	/* XXX -1 shouldn't be needed */
 	for (i = 0; i < UAUDIO_NCHANBUFS - 1; i++)
 		uaudio_chan_ptransfer(ch);
+	mutex_enter(>sc_lock);
 	mutex_enter(>sc_intr_lock);
 
 	return 0;



CVS commit: src

2017-05-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue May 16 23:21:54 UTC 2017

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4: Makefile virtio.4
Added Files:
src/share/man/man4: vioscsi.4

Log Message:
add vioscsi(4) manpage


To generate a diff of this commit:
cvs rdiff -u -r1.1554 -r1.1555 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.635 -r1.636 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/vioscsi.4
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/virtio.4

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

Modified files:

Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1554 src/distrib/sets/lists/man/mi:1.1555
--- src/distrib/sets/lists/man/mi:1.1554	Wed Apr 19 00:17:30 2017
+++ src/distrib/sets/lists/man/mi	Tue May 16 23:21:53 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1554 2017/04/19 00:17:30 riastradh Exp $
+# $NetBSD: mi,v 1.1555 2017/05/16 23:21:53 jdolecek Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1949,6 +1949,7 @@
 ./usr/share/man/cat4/vioif.0			man-sys-catman		.cat
 ./usr/share/man/cat4/viomb.0			man-sys-catman		.cat
 ./usr/share/man/cat4/viornd.0			man-sys-catman		.cat
+./usr/share/man/cat4/vioscsi.0			man-sys-catman		.cat
 ./usr/share/man/cat4/virt.0			man-sys-catman		.cat
 ./usr/share/man/cat4/virtio.0			man-sys-catman		.cat
 ./usr/share/man/cat4/vlan.0			man-sys-catman		.cat
@@ -4980,6 +4981,7 @@
 ./usr/share/man/html4/vioif.html		man-sys-htmlman		html
 ./usr/share/man/html4/viomb.html		man-sys-htmlman		html
 ./usr/share/man/html4/viornd.html		man-sys-htmlman		html
+./usr/share/man/html4/vioscsi.html		man-sys-htmlman		html
 ./usr/share/man/html4/virt.html			man-sys-htmlman		html
 ./usr/share/man/html4/virtio.html		man-sys-htmlman		html
 ./usr/share/man/html4/vlan.html			man-sys-htmlman		html
@@ -7943,6 +7945,7 @@
 ./usr/share/man/man4/vioif.4			man-sys-man		.man
 ./usr/share/man/man4/viomb.4			man-sys-man		.man
 ./usr/share/man/man4/viornd.4			man-sys-man		.man
+./usr/share/man/man4/vioscsi.4			man-sys-man		.man
 ./usr/share/man/man4/virt.4			man-sys-man		.man
 ./usr/share/man/man4/virtio.4			man-sys-man		.man
 ./usr/share/man/man4/vlan.4			man-sys-man		.man

Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.635 src/share/man/man4/Makefile:1.636
--- src/share/man/man4/Makefile:1.635	Wed Apr 19 00:17:31 2017
+++ src/share/man/man4/Makefile	Tue May 16 23:21:53 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.635 2017/04/19 00:17:31 riastradh Exp $
+#	$NetBSD: Makefile,v 1.636 2017/05/16 23:21:53 jdolecek Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -66,7 +66,7 @@ MAN=	aac.4 ac97.4 acardide.4 aceride.4 a
 	trm.4 tty.4 tun.4 tqphy.4 twa.4 twe.4 txp.4 \
 	uark.4 ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 unix.4 userconf.4 \
 	vald.4 valz.4 veriexec.4 vga.4 vge.4 viaide.4 video.4 vioif.4 viomb.4 \
-	viornd.4 virt.4 \
+	viornd.4 vioscsi.4 virt.4 \
 	virtio.4 vlan.4 vmmon.4 vmnet.4 vnd.4 voodoofb.4 vr.4 vte.4 \
 	wapbl.4 wb.4 wbsio.4 wd.4 wdc.4 wi.4 wm.4 wpi.4 \
 	wscons.4 wsdisplay.4 wsfont.4 wskbd.4 wsmouse.4 wsmux.4 \

Index: src/share/man/man4/virtio.4
diff -u src/share/man/man4/virtio.4:1.7 src/share/man/man4/virtio.4:1.8
--- src/share/man/man4/virtio.4:1.7	Thu Jan 26 13:52:29 2017
+++ src/share/man/man4/virtio.4	Tue May 16 23:21:53 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: virtio.4,v 1.7 2017/01/26 13:52:29 wiz Exp $
+.\"	$NetBSD: virtio.4,v 1.8 2017/05/16 23:21:53 jdolecek Exp $
 .\"
 .\" Copyright (c) 2011 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 26, 2017
+.Dd May 17, 2017
 .Dt VIRTIO 4
 .Os
 .Sh NAME
@@ -36,6 +36,7 @@
 .Cd "vioif* at virtio?"
 .Cd "viomb* at virtio?"
 .Cd "viornd* at virtio?"
+.Cd "vioscsi* at virtio?"
 .Sh DESCRIPTION
 .Nm
 defines an interface for efficient, standard and extensible I/O between the
@@ -57,13 +58,16 @@ An Ethernet device.
 A pseudo-device to release memory back to the hypervisor.
 .It Xr viornd 4
 An entropy source.
+.It Xr vioscsi 4
+A SCSI adapter.
 .El
 .Sh SEE ALSO
 .Xr ld 4 ,
 .Xr pci 4 ,
 .Xr vioif 4 ,
 .Xr viomb 4 ,
-.Xr viornd 4
+.Xr viornd 4 ,
+.Xr vioscsi 4
 .Pp
 .Rs
 .%A Rusty Russell, IBM Corporation

Added files:

Index: src/share/man/man4/vioscsi.4
diff -u /dev/null src/share/man/man4/vioscsi.4:1.1
--- /dev/null	Tue May 16 23:21:54 2017
+++ src/share/man/man4/vioscsi.4	Tue May 16 23:21:53 2017
@@ -0,0 +1,66 @@
+.\" $NetBSD: vioscsi.4,v 1.1 2017/05/16 23:21:53 jdolecek Exp $
+.\"
+.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" 

CVS commit: src

2017-05-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue May 16 23:21:54 UTC 2017

Modified Files:
src/distrib/sets/lists/man: mi
src/share/man/man4: Makefile virtio.4
Added Files:
src/share/man/man4: vioscsi.4

Log Message:
add vioscsi(4) manpage


To generate a diff of this commit:
cvs rdiff -u -r1.1554 -r1.1555 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.635 -r1.636 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/vioscsi.4
cvs rdiff -u -r1.7 -r1.8 src/share/man/man4/virtio.4

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



CVS commit: src/doc

2017-05-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue May 16 23:00:42 UTC 2017

Modified Files:
src/doc: CHANGES

Log Message:
mention recent vioscsi/virtio changes


To generate a diff of this commit:
cvs rdiff -u -r1.2281 -r1.2282 src/doc/CHANGES

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



CVS commit: src/doc

2017-05-16 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue May 16 23:00:42 UTC 2017

Modified Files:
src/doc: CHANGES

Log Message:
mention recent vioscsi/virtio changes


To generate a diff of this commit:
cvs rdiff -u -r1.2281 -r1.2282 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2281 src/doc/CHANGES:1.2282
--- src/doc/CHANGES:1.2281	Wed May 10 11:05:17 2017
+++ src/doc/CHANGES	Tue May 16 23:00:42 2017
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2281 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2282 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -483,6 +483,8 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	siginfo(2): Add new si_code values for SIGTRAP: TRAP_SCE and TRAP_SCX
 		[kamil 20170228]
 	zoneinfo: Import tzdata2017a.  [kre 20170301]
+	vioscsi(4): Allocate bus dma maps on attach, improves stability
+		and performance, adresses kern/52043 [jdolecek 20170307]
 	luna68k: Add a driver for LUNA's front panel LCD.  Ported from
 		OpenBSD/luna88k. [tsutsui 20170309]
 	sqlite3: Import 3.17.0. [christos 20170311]
@@ -492,6 +494,9 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 		adding support for all required operators, as well
 		as being smaller and faster.  [kre 20170320]
 	zoneinfo: Import tzdata2017b.  [kre 20170321]
+	virtio(4): Refactor child driver attach code for better modularization
+		[jdolecek 20170325]
+	vioscsi(4): Use MSI/MSI-X, reduce disk probe time [jdolecek 20170325]
 	dhcpcd(8): Import dhcpcd-7.0.0-beta2 [roy 20170402]
 	ptrace(2): Add operations to single step specified threads:
 		PT_SETSTEP and PT_CLEARSTEP [kamil 20170408]
@@ -507,3 +512,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0:
 	acpi(4): Updated ACPICA to 20170303. [christos 20170430]
 	openpam(3): update to 20170430 (resedacea) [christos 20170506]
 	dhcpcd: Import dhcpcd 7.0.0-rc1 [roy 20170510]
+	vioscsi(4): Stability fixes [jdolecek 20170515]



CVS commit: [netbsd-7] src/doc

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 22:52:58 UTC 2017

Modified Files:
src/doc [netbsd-7]: CHANGES-7.2

Log Message:
amend 1406


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.17 -r1.1.2.18 src/doc/CHANGES-7.2

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

Modified files:

Index: src/doc/CHANGES-7.2
diff -u src/doc/CHANGES-7.2:1.1.2.17 src/doc/CHANGES-7.2:1.1.2.18
--- src/doc/CHANGES-7.2:1.1.2.17	Sat May 13 06:31:44 2017
+++ src/doc/CHANGES-7.2	Tue May 16 22:52:57 2017
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-7.2,v 1.1.2.17 2017/05/13 06:31:44 snj Exp $
+# $NetBSD: CHANGES-7.2,v 1.1.2.18 2017/05/16 22:52:57 snj Exp $
 
 A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2
 release:
@@ -1067,6 +1067,7 @@ sys/netinet6/nd6.c1.203 via patch
 
 sys/arch/mips/include/ecoff_machdep.h		1.23
 sys/sys/exec_ecoff.h1.21
+sys/sys/exec_elf.h1.156
 tools/Makefile.nbincludes			1.5
 tools/mips-elf2ecoff/Makefile			1.3
 tools/mips-elf2ecoff/machine/ecoff_machdep.h	1.3



CVS commit: [netbsd-7] src/doc

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 22:52:58 UTC 2017

Modified Files:
src/doc [netbsd-7]: CHANGES-7.2

Log Message:
amend 1406


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.17 -r1.1.2.18 src/doc/CHANGES-7.2

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



CVS commit: [netbsd-7] src/sys/sys

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 22:52:17 UTC 2017

Modified Files:
src/sys/sys [netbsd-7]: exec_elf.h

Log Message:
Pull up following revision to fix fallout from ticket #1406:
sys/sys/exec_elf.h: revision 1.156
Add mips abiflags section


To generate a diff of this commit:
cvs rdiff -u -r1.141.2.2 -r1.141.2.3 src/sys/sys/exec_elf.h

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



CVS commit: [netbsd-7] src/sys/sys

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 22:52:17 UTC 2017

Modified Files:
src/sys/sys [netbsd-7]: exec_elf.h

Log Message:
Pull up following revision to fix fallout from ticket #1406:
sys/sys/exec_elf.h: revision 1.156
Add mips abiflags section


To generate a diff of this commit:
cvs rdiff -u -r1.141.2.2 -r1.141.2.3 src/sys/sys/exec_elf.h

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

Modified files:

Index: src/sys/sys/exec_elf.h
diff -u src/sys/sys/exec_elf.h:1.141.2.2 src/sys/sys/exec_elf.h:1.141.2.3
--- src/sys/sys/exec_elf.h:1.141.2.2	Mon Mar  7 08:08:52 2016
+++ src/sys/sys/exec_elf.h	Tue May 16 22:52:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.h,v 1.141.2.2 2016/03/07 08:08:52 msaitoh Exp $	*/
+/*	$NetBSD: exec_elf.h,v 1.141.2.3 2017/05/16 22:52:17 snj Exp $	*/
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -354,6 +354,7 @@ typedef struct {
 #define PT_HIPROC	0x7fff
 
 #define PT_MIPS_REGINFO 0x7000
+#define PT_MIPS_ABIFLAGS 0x7003
 
 /* p_flags */
 #define PF_R		0x4		/* Segment is readable */



CVS commit: src/sys/dev

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 21:43:18 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Revert the changes made with holding sc_lock in audiostartp/startr made in
rev 1.347.  The audio tests should run again.


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/sys/dev/audio.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/audio.c
diff -u src/sys/dev/audio.c:1.349 src/sys/dev/audio.c:1.350
--- src/sys/dev/audio.c:1.349	Mon May 15 12:07:32 2017
+++ src/sys/dev/audio.c	Tue May 16 21:43:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.349 2017/05/15 12:07:32 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.350 2017/05/16 21:43:18 nat Exp $	*/
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss 
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.349 2017/05/15 12:07:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.350 2017/05/16 21:43:18 nat Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -3485,12 +3485,10 @@ audiostartr(struct audio_softc *sc, stru
 		return EINVAL;
 
 	if (sc->sc_rec_started == false) {
-		mutex_exit(sc->sc_lock);
 		mutex_enter(sc->sc_intr_lock);
 		mix_read(sc);
 		cv_broadcast(>sc_rcondvar);
 		mutex_exit(sc->sc_intr_lock);
-		mutex_enter(sc->sc_lock);
 	}
 	vc->sc_rbus = true;
 
@@ -3525,7 +3523,6 @@ audiostartp(struct audio_softc *sc, stru
 	if (sc->sc_trigger_started == false) {
 		audio_mix(sc);
 		audio_mix(sc);
-		mutex_exit(sc->sc_lock);
 		mutex_enter(sc->sc_intr_lock);
 		mix_write(sc);
 		vc = chan->vc;
@@ -3535,7 +3532,6 @@ audiostartp(struct audio_softc *sc, stru
 		mix_write(sc);
 		cv_broadcast(>sc_condvar);
 		mutex_exit(sc->sc_intr_lock);
-		mutex_enter(sc->sc_lock);
 	}
 
 	return error;



CVS commit: src/sys/dev

2017-05-16 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue May 16 21:43:18 UTC 2017

Modified Files:
src/sys/dev: audio.c

Log Message:
Revert the changes made with holding sc_lock in audiostartp/startr made in
rev 1.347.  The audio tests should run again.


To generate a diff of this commit:
cvs rdiff -u -r1.349 -r1.350 src/sys/dev/audio.c

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



CVS commit: src/distrib/notes/common

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 17:40:01 UTC 2017

Modified Files:
src/distrib/notes/common: main

Log Message:
update core


To generate a diff of this commit:
cvs rdiff -u -r1.534 -r1.535 src/distrib/notes/common/main

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



CVS commit: src/distrib/notes/common

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 17:40:01 UTC 2017

Modified Files:
src/distrib/notes/common: main

Log Message:
update core


To generate a diff of this commit:
cvs rdiff -u -r1.534 -r1.535 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.534 src/distrib/notes/common/main:1.535
--- src/distrib/notes/common/main:1.534	Fri Mar 10 04:13:43 2017
+++ src/distrib/notes/common/main	Tue May 16 17:40:01 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: main,v 1.534 2017/03/10 04:13:43 salazar Exp $
+.\"	$NetBSD: main,v 1.535 2017/05/16 17:40:01 snj Exp $
 .\"
 .\" Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1028,9 +1028,9 @@ If you're one of them, and would like to
 .br_ne 1i
 .It Em "The NetBSD core group:"
 .It Ta Ta
-.It Ta Alan Barrett Ta Mt a...@netbsd.org
 .It Ta Alistair Crooks Ta Mt a...@netbsd.org
 .It Ta Matthew Green Ta Mt m...@netbsd.org
+.It Ta Martin Husemann Ta Mt mar...@netbsd.org
 .It Ta Chuck Silvers Ta Mt c...@netbsd.org
 .It Ta Matt Thomas Ta Mt m...@netbsd.org
 .It Ta YAMAMOTO Takashi Ta Mt y...@netbsd.org



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 12:03:41 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Improve the scope of some variables.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libterminfo/term.c

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



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 12:03:41 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Improve the scope of some variables.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.27 src/lib/libterminfo/term.c:1.28
--- src/lib/libterminfo/term.c:1.27	Tue May 16 11:16:37 2017
+++ src/lib/libterminfo/term.c	Tue May 16 12:03:41 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.27 2017/05/16 11:16:37 roy Exp $ */
+/* $NetBSD: term.c,v 1.28 2017/05/16 12:03:41 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.27 2017/05/16 11:16:37 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.28 2017/05/16 12:03:41 roy Exp $");
 
 #include 
 
@@ -349,10 +349,7 @@ static int
 _ti_findterm(TERMINAL *term, const char *name, int flags)
 {
 	int r;
-	char *c, *e, h[PATH_MAX];
-	TIC *tic;
-	uint8_t *f;
-	ssize_t len;
+	char *c, *e;
 
 	_DIAGASSERT(term != NULL);
 	_DIAGASSERT(name != NULL);
@@ -377,6 +374,8 @@ _ti_findterm(TERMINAL *term, const char 
 	}
 
 	if (e != NULL) {
+		TIC *tic;
+
 		if (c == NULL)
 			e = strdup(e); /* So we don't destroy env */
 		if (e == NULL)
@@ -389,6 +388,9 @@ _ti_findterm(TERMINAL *term, const char 
 		if (tic != NULL &&
 		_ti_checkname(name, tic->name, tic->alias) == 1)
 		{
+			uint8_t *f;
+			ssize_t len;
+
 			len = _ti_flatten(, tic);
 			if (len != -1) {
 r = _ti_readterm(term, (char *)f, (size_t)len,
@@ -410,8 +412,10 @@ _ti_findterm(TERMINAL *term, const char 
 		return _ti_dbgettermp(term, e, name, flags);
 
 	if ((e = getenv("HOME")) != NULL) {
-		snprintf(h, sizeof(h), "%s/.terminfo", e);
-		r = _ti_dbgetterm(term, h, name, flags);
+		char homepath[PATH_MAX];
+
+		if (snprintf(homepath, sizeof(homepath), "%s/.terminfo", e) > 0)
+			r = _ti_dbgetterm(term, homepath, name, flags);
 	}
 	if (r != 1)
 		r = _ti_dbgettermp(term, _PATH_TERMINFO, name, flags);



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 11:16:37 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Remove ticcmp and extend _ti_checkname so it can be used instead.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.26 src/lib/libterminfo/term.c:1.27
--- src/lib/libterminfo/term.c:1.26	Tue May 16 10:29:06 2017
+++ src/lib/libterminfo/term.c	Tue May 16 11:16:37 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.26 2017/05/16 10:29:06 roy Exp $ */
+/* $NetBSD: term.c,v 1.27 2017/05/16 11:16:37 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.26 2017/05/16 10:29:06 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.27 2017/05/16 11:16:37 roy Exp $");
 
 #include 
 
@@ -243,27 +243,32 @@ out:
 }
 
 static int
-_ti_checkname(const TERMINAL *term, const char *name)
+_ti_checkname(const char *name, const char *termname, const char *termalias)
 {
-	const char *a, *p;
-	size_t name_len;
+	const char *alias, *s;
+	size_t len, l;
 
 	/* Check terminal name matches. */
-	if (strcmp(name, term->name) == 0)
+	if (strcmp(termname, name) == 0)
 		return 1;
 
 	/* Check terminal aliases match. */
-	name_len = strlen(name);
-	for (a = term->_alias; a != NULL && *a != '\0'; a = p) {
-		for (p = a; *p != '\0'; p++) {
-			if (*p == '|')
-break;
-		}
-		if ((size_t)(p - a) == name_len &&
-		memcmp(name, a, name_len) == 0)
+	if (termalias == NULL)
+		return 0;
+
+	len = strlen(name);
+	alias = termalias;
+	while (*alias != '\0') {
+		s = strchr(alias, '|');
+		if (s == NULL)
+			l = strlen(alias);
+		else
+			l = (size_t)(s - alias);
+		if (len == l && memcmp(alias, name, l) == 0)
 			return 1;
-		if (*p == '|')
-			p++;
+		if (s == NULL)
+			break;
+		alias = s + 1;
 	}
 
 	/* No match. */
@@ -303,7 +308,7 @@ _ti_dbgetterm(TERMINAL *term, const char
 	r = _ti_readterm(term, data, len, flags);
 	/* Ensure that this is the right terminfo description. */
 if (r == 1)
-r = _ti_checkname(term, name);
+r = _ti_checkname(name, term->name, term->_alias);
 	/* Remember the database we read. */
 if (r == 1)
 _ti_database = __ti_database;
@@ -341,34 +346,6 @@ _ti_dbgettermp(TERMINAL *term, const cha
 }
 
 static int
-ticcmp(const TIC *tic, const char *name)
-{
-	char *alias, *s;
-	size_t len, l;
-
-	if (strcmp(tic->name, name) == 0)
-		return 0;
-	if (tic->alias == NULL)
-		return -1;
-
-	len = strlen(name);
-	alias = tic->alias;
-	while (*alias != '\0') {
-		s = strchr(alias, '|');
-		if (s == NULL)
-			l = strlen(alias);
-		else
-			l = (size_t)(s - alias);
-		if (len == l && memcmp(alias, name, l) == 0)
-			return 0;
-		if (s == NULL)
-			break;
-		alias = s + 1;
-	}
-	return 1;
-}
-
-static int
 _ti_findterm(TERMINAL *term, const char *name, int flags)
 {
 	int r;
@@ -380,7 +357,6 @@ _ti_findterm(TERMINAL *term, const char 
 	_DIAGASSERT(term != NULL);
 	_DIAGASSERT(name != NULL);
 
-	__ti_database[0] = '\0';
 	_ti_database = NULL;
 	r = 0;
 
@@ -410,7 +386,9 @@ _ti_findterm(TERMINAL *term, const char 
 			TIC_ALIAS | TIC_DESCRIPTION | TIC_EXTRA);
 			free(e);
 		}
-		if (tic != NULL && ticcmp(tic, name) == 0) {
+		if (tic != NULL &&
+		_ti_checkname(name, tic->name, tic->alias) == 1)
+		{
 			len = _ti_flatten(, tic);
 			if (len != -1) {
 r = _ti_readterm(term, (char *)f, (size_t)len,



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 11:16:37 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Remove ticcmp and extend _ti_checkname so it can be used instead.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libterminfo/term.c

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



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 10:29:06 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Fix prior for multiple terminfo aliases.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.25 src/lib/libterminfo/term.c:1.26
--- src/lib/libterminfo/term.c:1.25	Tue May 16 10:25:40 2017
+++ src/lib/libterminfo/term.c	Tue May 16 10:29:06 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.25 2017/05/16 10:25:40 roy Exp $ */
+/* $NetBSD: term.c,v 1.26 2017/05/16 10:29:06 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.25 2017/05/16 10:25:40 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.26 2017/05/16 10:29:06 roy Exp $");
 
 #include 
 
@@ -262,6 +262,8 @@ _ti_checkname(const TERMINAL *term, cons
 		if ((size_t)(p - a) == name_len &&
 		memcmp(name, a, name_len) == 0)
 			return 1;
+		if (*p == '|')
+			p++;
 	}
 
 	/* No match. */



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 10:29:06 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Fix prior for multiple terminfo aliases.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libterminfo/term.c

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



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 10:25:40 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Instead of poking in the binary blob to work out if this is our terminal,
assume it is and load it.
Once loaded then check it's really for us.
This allows us to work out if the indexed alias entry is correct we
this was not checked previously.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.24 src/lib/libterminfo/term.c:1.25
--- src/lib/libterminfo/term.c:1.24	Tue May 16 09:19:48 2017
+++ src/lib/libterminfo/term.c	Tue May 16 10:25:40 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $ */
+/* $NetBSD: term.c,v 1.25 2017/05/16 10:25:40 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.25 2017/05/16 10:25:40 roy Exp $");
 
 #include 
 
@@ -243,6 +243,32 @@ out:
 }
 
 static int
+_ti_checkname(const TERMINAL *term, const char *name)
+{
+	const char *a, *p;
+	size_t name_len;
+
+	/* Check terminal name matches. */
+	if (strcmp(name, term->name) == 0)
+		return 1;
+
+	/* Check terminal aliases match. */
+	name_len = strlen(name);
+	for (a = term->_alias; a != NULL && *a != '\0'; a = p) {
+		for (p = a; *p != '\0'; p++) {
+			if (*p == '|')
+break;
+		}
+		if ((size_t)(p - a) == name_len &&
+		memcmp(name, a, name_len) == 0)
+			return 1;
+	}
+
+	/* No match. */
+	return 0;
+}
+
+static int
 _ti_dbgetterm(TERMINAL *term, const char *path, const char *name, int flags)
 {
 	struct cdbr *db;
@@ -257,39 +283,32 @@ _ti_dbgetterm(TERMINAL *term, const char
 	if (db == NULL)
 		return -1;
 
+	r = 0;
 	klen = strlen(name) + 1;
 	if (cdbr_find(db, name, klen, , ) == -1)
-		goto fail;
+		goto out;
 	data8 = data;
 	if (len == 0)
-		goto fail;
-	/* Check for alias first, fall through to processing normal entries. */
+		goto out;
+
+	/* If the entry is an alias, load the indexed terminfo description. */
 	if (data8[0] == 2) {
-		if (klen + 7 > len || le16dec(data8 + 5) != klen)
-			goto fail;
-		if (memcmp(data8 + 7, name, klen))
-			goto fail;
 		if (cdbr_get(db, le32dec(data8 + 1), , ))
-			goto fail;
+			goto out;
 		data8 = data;
-		if (data8[0] != 1)
-			goto fail;
-	} else if (data8[0] != 1)
-		goto fail;
-	else if (klen + 3 >= len || le16dec(data8 + 1) != klen)
-		goto fail;
-	else if (memcmp(data8 + 3, name, klen))
-		goto fail;
-
-	_ti_database = __ti_database;
+	}
 
 	r = _ti_readterm(term, data, len, flags);
-	cdbr_close(db);
-	return r;
+	/* Ensure that this is the right terminfo description. */
+if (r == 1)
+r = _ti_checkname(term, name);
+	/* Remember the database we read. */
+if (r == 1)
+_ti_database = __ti_database;
 
-fail:
+out:
 	cdbr_close(db);
-	return 0;
+	return r;
 }
 
 static int



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 10:25:40 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Instead of poking in the binary blob to work out if this is our terminal,
assume it is and load it.
Once loaded then check it's really for us.
This allows us to work out if the indexed alias entry is correct we
this was not checked previously.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libterminfo/term.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 10:11:24 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Replace kmem_alloc + memset with kmem_zalloc

Suggested by kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/netipsec/key.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 10:11:24 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Replace kmem_alloc + memset with kmem_zalloc

Suggested by kamil@


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.129 src/sys/netipsec/key.c:1.130
--- src/sys/netipsec/key.c:1.129	Tue May 16 07:43:50 2017
+++ src/sys/netipsec/key.c	Tue May 16 10:11:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.129 2017/05/16 07:43:50 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.130 2017/05/16 10:11:24 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.129 2017/05/16 07:43:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.130 2017/05/16 10:11:24 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -1544,8 +1544,7 @@ key_msg2sp(const struct sadb_x_policy *x
 		}
 
 		/* allocate request buffer */
-		*p_isr = kmem_alloc(sizeof(**p_isr), KM_SLEEP);
-		memset(*p_isr, 0, sizeof(**p_isr));
+		*p_isr = kmem_zalloc(sizeof(**p_isr), KM_SLEEP);
 
 		/* set values */
 		(*p_isr)->next = NULL;
@@ -2966,8 +2965,7 @@ key_newsav(struct mbuf *m, const struct 
 	KASSERT(mhp->msg != NULL);
 	KASSERT(sah != NULL);
 
-	newsav = kmem_alloc(sizeof(struct secasvar), KM_SLEEP);
-	memset(newsav, 0, sizeof(struct secasvar));
+	newsav = kmem_zalloc(sizeof(struct secasvar), KM_SLEEP);
 
 	switch (mhp->msg->sadb_msg_type) {
 	case SADB_GETSPI:
@@ -6433,12 +6431,11 @@ key_newacq(const struct secasindex *said
 	struct secacq *newacq;
 
 	/* get new entry */
-	newacq = kmem_intr_alloc(sizeof(struct secacq), KM_NOSLEEP);
+	newacq = kmem_intr_zalloc(sizeof(struct secacq), KM_NOSLEEP);
 	if (newacq == NULL) {
 		ipseclog((LOG_DEBUG, "key_newacq: No more memory.\n"));
 		return NULL;
 	}
-	memset(newacq, 0, sizeof(*newacq));
 
 	/* copy secindex */
 	memcpy(>saidx, saidx, sizeof(newacq->saidx));
@@ -6482,12 +6479,11 @@ key_newspacq(const struct secpolicyindex
 	struct secspacq *acq;
 
 	/* get new entry */
-	acq = kmem_intr_alloc(sizeof(struct secspacq), KM_NOSLEEP);
+	acq = kmem_intr_zalloc(sizeof(struct secspacq), KM_NOSLEEP);
 	if (acq == NULL) {
 		ipseclog((LOG_DEBUG, "key_newspacq: No more memory.\n"));
 		return NULL;
 	}
-	memset(acq, 0, sizeof(*acq));
 
 	/* copy secindex */
 	memcpy(>spidx, spidx, sizeof(acq->spidx));
@@ -6672,8 +6668,7 @@ key_register(struct socket *so, struct m
 	}
 
 	/* create regnode */
-	newreg = kmem_alloc(sizeof(*newreg), KM_SLEEP);
-	memset(newreg, 0, sizeof(*newreg));
+	newreg = kmem_zalloc(sizeof(*newreg), KM_SLEEP);
 
 	newreg->so = so;
 	((struct keycb *)sotorawcb(so))->kp_registered++;



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 09:19:49 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Don't bother allocating space for the database name, just print
directly to the static buffer storage.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.23 src/lib/libterminfo/term.c:1.24
--- src/lib/libterminfo/term.c:1.23	Tue May 16 08:52:14 2017
+++ src/lib/libterminfo/term.c	Tue May 16 09:19:48 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $ */
+/* $NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.24 2017/05/16 09:19:48 roy Exp $");
 
 #include 
 
@@ -46,7 +46,7 @@ __RCSID("$NetBSD: term.c,v 1.23 2017/05/
 
 #define _PATH_TERMINFO		"/usr/share/misc/terminfo"
 
-static char database[PATH_MAX];
+static char __ti_database[PATH_MAX];
 const char *_ti_database;
 
 /* Include a generated list of pre-compiled terminfo descriptions. */
@@ -247,16 +247,13 @@ _ti_dbgetterm(TERMINAL *term, const char
 {
 	struct cdbr *db;
 	const void *data;
-	char *db_name;
 	const uint8_t *data8;
 	size_t len, klen;
 	int r;
 
-	if (asprintf(_name, "%s.cdb", path) < 0)
+	if (snprintf(__ti_database, sizeof(__ti_database), "%s.cdb", path) < 0)
 		return -1;
-
-	db = cdbr_open(db_name, CDBR_DEFAULT);
-	free(db_name);
+	db = cdbr_open(__ti_database, CDBR_DEFAULT);
 	if (db == NULL)
 		return -1;
 
@@ -284,8 +281,7 @@ _ti_dbgetterm(TERMINAL *term, const char
 	else if (memcmp(data8 + 3, name, klen))
 		goto fail;
 
-	strlcpy(database, path, sizeof(database));
-	_ti_database = database;
+	_ti_database = __ti_database;
 
 	r = _ti_readterm(term, data, len, flags);
 	cdbr_close(db);
@@ -363,7 +359,7 @@ _ti_findterm(TERMINAL *term, const char 
 	_DIAGASSERT(term != NULL);
 	_DIAGASSERT(name != NULL);
 
-	database[0] = '\0';
+	__ti_database[0] = '\0';
 	_ti_database = NULL;
 	r = 0;
 



CVS commit: src/usr.bin/infocmp

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 09:21:54 UTC 2017

Modified Files:
src/usr.bin/infocmp: infocmp.c

Log Message:
_ti_database now includes the database extension so don't duplicate it.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/infocmp/infocmp.c

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



CVS commit: src/usr.bin/infocmp

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 09:21:54 UTC 2017

Modified Files:
src/usr.bin/infocmp: infocmp.c

Log Message:
_ti_database now includes the database extension so don't duplicate it.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/infocmp/infocmp.c

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

Modified files:

Index: src/usr.bin/infocmp/infocmp.c
diff -u src/usr.bin/infocmp/infocmp.c:1.11 src/usr.bin/infocmp/infocmp.c:1.12
--- src/usr.bin/infocmp/infocmp.c:1.11	Wed Mar 16 21:01:28 2016
+++ src/usr.bin/infocmp/infocmp.c	Tue May 16 09:21:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: infocmp.c,v 1.11 2016/03/16 21:01:28 christos Exp $ */
+/* $NetBSD: infocmp.c,v 1.12 2017/05/16 09:21:54 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: infocmp.c,v 1.11 2016/03/16 21:01:28 christos Exp $");
+__RCSID("$NetBSD: infocmp.c,v 1.12 2017/05/16 09:21:54 roy Exp $");
 
 #include 
 
@@ -712,14 +712,10 @@ main(int argc, char **argv)
 		use_terms(t, argc - optind, argv + optind);
 
 	if ((optind + 1 != argc && nflag == 0) || uflag != 0) {
-		if (uflag == 0) {
-			printf("# Reconstructed from ");
-			if (_ti_database == NULL)
-printf("internal database\n");
-			else
-printf("%s%s\n", _ti_database,
-*_ti_database == '/' ? ".cdb" : "");
-		}
+		if (uflag == 0)
+			printf("# Reconstructed from %s\n",
+			 _ti_database == NULL ?
+			 "internal database" : _ti_database);
 		printf("%s", t->name);
 		if (t->_alias != NULL && *t->_alias != '\0')
 			printf("|%s", t->_alias);



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 09:19:49 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Don't bother allocating space for the database name, just print
directly to the static buffer storage.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libterminfo/term.c

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



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 08:52:14 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Move pathbuf into the function where it's actually used.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libterminfo/term.c

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

Modified files:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.22 src/lib/libterminfo/term.c:1.23
--- src/lib/libterminfo/term.c:1.22	Thu May  4 09:42:23 2017
+++ src/lib/libterminfo/term.c	Tue May 16 08:52:14 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.22 2017/05/04 09:42:23 roy Exp $ */
+/* $NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: term.c,v 1.22 2017/05/04 09:42:23 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.23 2017/05/16 08:52:14 roy Exp $");
 
 #include 
 
@@ -47,7 +47,6 @@ __RCSID("$NetBSD: term.c,v 1.22 2017/05/
 #define _PATH_TERMINFO		"/usr/share/misc/terminfo"
 
 static char database[PATH_MAX];
-static char pathbuf[PATH_MAX];
 const char *_ti_database;
 
 /* Include a generated list of pre-compiled terminfo descriptions. */
@@ -301,6 +300,7 @@ static int
 _ti_dbgettermp(TERMINAL *term, const char *path, const char *name, int flags)
 {
 	const char *p;
+	char pathbuf[PATH_MAX];
 	size_t l;
 	int r, e;
 



CVS commit: src/lib/libterminfo

2017-05-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 16 08:52:14 UTC 2017

Modified Files:
src/lib/libterminfo: term.c

Log Message:
Move pathbuf into the function where it's actually used.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libterminfo/term.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 07:43:50 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Fix memory leaks of sah->idents and sah->identd

Originally fixed by the SEIL team of IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/netipsec/key.c

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



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 07:43:50 UTC 2017

Modified Files:
src/sys/netipsec: key.c

Log Message:
Fix memory leaks of sah->idents and sah->identd

Originally fixed by the SEIL team of IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/netipsec/key.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/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.128 src/sys/netipsec/key.c:1.129
--- src/sys/netipsec/key.c:1.128	Tue May 16 07:25:57 2017
+++ src/sys/netipsec/key.c	Tue May 16 07:43:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.128 2017/05/16 07:25:57 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.129 2017/05/16 07:43:50 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.128 2017/05/16 07:25:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.129 2017/05/16 07:43:50 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -2929,6 +2929,11 @@ key_delsah(struct secashead *sah)
 	if (__LIST_CHAINED(sah))
 		LIST_REMOVE(sah, chain);
 
+	if (sah->idents != NULL)
+		KFREE(sah->idents);
+	if (sah->identd != NULL)
+		KFREE(sah->identd);
+
 	kmem_free(sah, sizeof(*sah));
 
 	splx(s);
@@ -5571,6 +5576,18 @@ key_setident(struct secashead *sah, stru
 	KASSERT(mhp != NULL);
 	KASSERT(mhp->msg != NULL);
 
+	/*
+	 * Can be called with an existing sah from key_update().
+	 */
+	if (sah->idents != NULL) {
+		KFREE(sah->idents);
+		sah->idents = NULL;
+	}
+	if (sah->identd != NULL) {
+		KFREE(sah->identd);
+		sah->identd = NULL;
+	}
+
 	/* don't make buffer if not there */
 	if (mhp->ext[SADB_EXT_IDENTITY_SRC] == NULL &&
 	mhp->ext[SADB_EXT_IDENTITY_DST] == NULL) {



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 07:25:57 UTC 2017

Modified Files:
src/sys/netipsec: ipsec.c key.c

Log Message:
Fix diagnostic assertion failure in ipsec_init_policy

  panic: kernel diagnostic assertion "!cpu_softintr_p()" failed: file 
"../../../../netipsec/ipsec.c", line 1277
  cpu7: Begin traceback...
  vpanic() at netbsd:vpanic+0x140
  ch_voltag_convert_in() at netbsd:ch_voltag_convert_in
  ipsec_init_policy() at netbsd:ipsec_init_policy+0x149
  in_pcballoc() at netbsd:in_pcballoc+0x1c5
  tcp_attach_wrapper() at netbsd:tcp_attach_wrapper+0x1e1
  sonewconn() at netbsd:sonewconn+0x1ea
  syn_cache_get() at netbsd:syn_cache_get+0x15f
  tcp_input() at netbsd:tcp_input+0x1689
  ipintr() at netbsd:ipintr+0xa88
  softint_dispatch() at netbsd:softint_dispatch+0xd3
  DDB lost frame for netbsd:Xsoftintr+0x4f, trying 0xfe811d337ff0
  Xsoftintr() at netbsd:Xsoftintr+0x4f

Reported by msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.127 -r1.128 src/sys/netipsec/key.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/netipsec/ipsec.c
diff -u src/sys/netipsec/ipsec.c:1.90 src/sys/netipsec/ipsec.c:1.91
--- src/sys/netipsec/ipsec.c:1.90	Tue May 16 03:05:28 2017
+++ src/sys/netipsec/ipsec.c	Tue May 16 07:25:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.c,v 1.90 2017/05/16 03:05:28 ozaki-r Exp $	*/
+/*	$NetBSD: ipsec.c,v 1.91 2017/05/16 07:25:57 ozaki-r Exp $	*/
 /*	$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $	*/
 /*	$KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.90 2017/05/16 03:05:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.91 2017/05/16 07:25:57 ozaki-r Exp $");
 
 /*
  * IPsec controller part.
@@ -1265,7 +1265,7 @@ static void
 ipsec_delpcbpolicy(struct inpcbpolicy *p)
 {
 
-	kmem_free(p, sizeof(*p));
+	kmem_intr_free(p, sizeof(*p));
 }
 
 /* initialize policy in PCB */
@@ -1274,11 +1274,14 @@ ipsec_init_policy(struct socket *so, str
 {
 	struct inpcbpolicy *new;
 
-	KASSERT(!cpu_softintr_p());
 	KASSERT(so != NULL);
 	KASSERT(policy != NULL);
 
-	new = kmem_zalloc(sizeof(*new), KM_SLEEP);
+	new = kmem_intr_zalloc(sizeof(*new), KM_NOSLEEP);
+	if (new == NULL) {
+		ipseclog((LOG_DEBUG, "%s: No more memory.\n", __func__));
+		return ENOBUFS;
+	}
 
 	if (IPSEC_PRIVILEGED_SO(so))
 		new->priv = 1;

Index: src/sys/netipsec/key.c
diff -u src/sys/netipsec/key.c:1.127 src/sys/netipsec/key.c:1.128
--- src/sys/netipsec/key.c:1.127	Tue May 16 03:05:28 2017
+++ src/sys/netipsec/key.c	Tue May 16 07:25:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: key.c,v 1.127 2017/05/16 03:05:28 ozaki-r Exp $	*/
+/*	$NetBSD: key.c,v 1.128 2017/05/16 07:25:57 ozaki-r Exp $	*/
 /*	$FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $	*/
 /*	$KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $	*/
 
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.127 2017/05/16 03:05:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.128 2017/05/16 07:25:57 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -1459,8 +1459,9 @@ key_newsp(const char* where, int tag)
 {
 	struct secpolicy *newsp = NULL;
 
-	newsp = kmem_zalloc(sizeof(struct secpolicy), KM_SLEEP);
-	newsp->refcnt = 1;
+	newsp = kmem_intr_zalloc(sizeof(struct secpolicy), KM_NOSLEEP);
+	if (newsp != NULL)
+		newsp->refcnt = 1;
 
 	KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
 	"DP from %s:%u return SP:%p\n", where, tag, newsp);



CVS commit: src/sys/netipsec

2017-05-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 16 07:25:57 UTC 2017

Modified Files:
src/sys/netipsec: ipsec.c key.c

Log Message:
Fix diagnostic assertion failure in ipsec_init_policy

  panic: kernel diagnostic assertion "!cpu_softintr_p()" failed: file 
"../../../../netipsec/ipsec.c", line 1277
  cpu7: Begin traceback...
  vpanic() at netbsd:vpanic+0x140
  ch_voltag_convert_in() at netbsd:ch_voltag_convert_in
  ipsec_init_policy() at netbsd:ipsec_init_policy+0x149
  in_pcballoc() at netbsd:in_pcballoc+0x1c5
  tcp_attach_wrapper() at netbsd:tcp_attach_wrapper+0x1e1
  sonewconn() at netbsd:sonewconn+0x1ea
  syn_cache_get() at netbsd:syn_cache_get+0x15f
  tcp_input() at netbsd:tcp_input+0x1689
  ipintr() at netbsd:ipintr+0xa88
  softint_dispatch() at netbsd:softint_dispatch+0xd3
  DDB lost frame for netbsd:Xsoftintr+0x4f, trying 0xfe811d337ff0
  Xsoftintr() at netbsd:Xsoftintr+0x4f

Reported by msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/netipsec/ipsec.c
cvs rdiff -u -r1.127 -r1.128 src/sys/netipsec/key.c

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



CVS commit: src/sys/dev/ic

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 06:16:35 UTC 2017

Modified Files:
src/sys/dev/ic: rtl8169.c

Log Message:
fix inverted logic.

spotted by "sc dying" on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/sys/dev/ic/rtl8169.c

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



CVS commit: src/sys/dev/ic

2017-05-16 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Tue May 16 06:16:35 UTC 2017

Modified Files:
src/sys/dev/ic: rtl8169.c

Log Message:
fix inverted logic.

spotted by "sc dying" on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/sys/dev/ic/rtl8169.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/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.150 src/sys/dev/ic/rtl8169.c:1.151
--- src/sys/dev/ic/rtl8169.c:1.150	Wed Apr 19 00:20:02 2017
+++ src/sys/dev/ic/rtl8169.c	Tue May 16 06:16:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.150 2017/04/19 00:20:02 jmcneill Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.151 2017/05/16 06:16:35 snj Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.150 2017/04/19 00:20:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.151 2017/05/16 06:16:35 snj Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -1916,7 +1916,7 @@ re_init(struct ifnet *ifp)
 	 */
 	if (sc->re_testmode)
 		CSR_WRITE_2(sc, RTK_IMR, 0);
-	else if ((sc->sc_quirk & RTKQ_IM_HW) == 0)
+	else if ((sc->sc_quirk & RTKQ_IM_HW) != 0)
 		CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_IM_HW);
 	else
 		CSR_WRITE_2(sc, RTK_IMR, RTK_INTRS_CPLUS);