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 <sys/cdefs.h>
-__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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/param.h>
@@ -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 = device_lookup_acquire(&cgd_cd, unit)) == NULL)
+ if ((*self = config_attach_pseudo(cf)) == NULL)
return NULL;
else {
/*
Index: src/sys/dev/fss.c
diff -u src/sys/dev/fss.c:1.97.4.3 src/sys/dev/fss.c:1.97.4.4
--- src/sys/dev/fss.c:1.97.4.3 Sat Apr 29 11:12:14 2017
+++ src/sys/dev/fss.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.97.4.3 2017/04/29 11:12:14 pgoyette Exp $ */
+/* $NetBSD: fss.c,v 1.97.4.4 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.97.4.3 2017/04/29 11:12:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.97.4.4 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -223,7 +223,6 @@ fss_open(dev_t dev, int flags, int mode,
cf->cf_unit = minor(dev);
cf->cf_fstate = FSTATE_STAR;
self = config_attach_pseudo(cf);
- device_acquire(self);
sc = device_private(self);
if (sc == NULL) {
device_release(self);
Index: src/sys/dev/md.c
diff -u src/sys/dev/md.c:1.78.6.5 src/sys/dev/md.c:1.78.6.6
--- src/sys/dev/md.c:1.78.6.5 Sun May 14 05:38:38 2017
+++ src/sys/dev/md.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.78.6.5 2017/05/14 05:38:38 pgoyette Exp $ */
+/* $NetBSD: md.c,v 1.78.6.6 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.5 2017/05/14 05:38:38 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.78.6.6 2017/05/17 01:44:17 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_md.h"
@@ -262,7 +262,6 @@ static int
mdopen(dev_t dev, int flag, int fmt, struct lwp *l)
{
device_t self;
- device_t new_self __diagused;
int unit;
int part = DISKPART(dev);
int pmask = 1 << part;
@@ -286,9 +285,7 @@ mdopen(dev_t dev, int flag, int fmt, str
cf->cf_atname = md_cd.cd_name;
cf->cf_unit = unit;
cf->cf_fstate = FSTATE_STAR;
- new_self = config_attach_pseudo(cf);
- self = device_lookup_acquire(&md_cd, unit);
- KASSERT(self == new_self);
+ self = config_attach_pseudo(cf);
sc = device_private(self);
if (sc == NULL) {
mutex_exit(&md_device_lock);
Index: src/sys/dev/vnd.c
diff -u src/sys/dev/vnd.c:1.259.4.4 src/sys/dev/vnd.c:1.259.4.5
--- src/sys/dev/vnd.c:1.259.4.4 Sat Apr 29 10:50:46 2017
+++ src/sys/dev/vnd.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.259.4.4 2017/04/29 10:50:46 pgoyette Exp $ */
+/* $NetBSD: vnd.c,v 1.259.4.5 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.4 2017/04/29 10:50:46 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.259.4.5 2017/05/17 01:44:17 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_vnd.h"
@@ -311,8 +311,6 @@ vnd_spawn(int unit)
/* Attach a new unit */
self = config_attach_pseudo(cf);
- /* And acquire a reference to it */
- self = device_lookup_acquire(&vnd_cd, unit);
if (self == NULL)
return NULL;
else {
Index: src/sys/dev/ata/ata_raid.c
diff -u src/sys/dev/ata/ata_raid.c:1.39 src/sys/dev/ata/ata_raid.c:1.39.6.1
--- src/sys/dev/ata/ata_raid.c:1.39 Tue Sep 27 08:05:34 2016
+++ src/sys/dev/ata/ata_raid.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $ */
+/* $NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39 2016/09/27 08:05:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid.c,v 1.39.6.1 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -155,6 +155,7 @@ ata_raid_type_name(u_int type)
static int
ata_raid_finalize(device_t self)
{
+ stgruct device_t dev;
static struct cfdata ataraid_cfdata = {
.cf_name = "ataraid",
.cf_atname = "ataraid",
@@ -172,9 +173,10 @@ ata_raid_finalize(device_t self)
if (TAILQ_EMPTY(&ataraid_array_info_list))
goto out;
- if (config_attach_pseudo(&ataraid_cfdata) == NULL)
+ if ((dev = config_attach_pseudo(&ataraid_cfdata)) == NULL)
printf("%s: unable to attach an instance\n",
ataraid_cd.cd_name);
+ device_release(dev);
out:
return (1);
Index: src/sys/dev/bluetooth/bcsp.c
diff -u src/sys/dev/bluetooth/bcsp.c:1.30 src/sys/dev/bluetooth/bcsp.c:1.30.6.1
--- src/sys/dev/bluetooth/bcsp.c:1.30 Mon Aug 15 08:20:11 2016
+++ src/sys/dev/bluetooth/bcsp.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: bcsp.c,v 1.30 2016/08/15 08:20:11 maxv Exp $ */
+/* $NetBSD: bcsp.c,v 1.30.6.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* Copyright (c) 2007 KIYOHARA Takashi
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.30 2016/08/15 08:20:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.30.6.1 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -422,6 +422,7 @@ bcspopen(dev_t device __unused, struct t
/* start link-establishment */
bcsp_start_le(sc);
+ device_release(dev);
return 0;
}
Index: src/sys/dev/bluetooth/btuart.c
diff -u src/sys/dev/bluetooth/btuart.c:1.28 src/sys/dev/bluetooth/btuart.c:1.28.8.1
--- src/sys/dev/bluetooth/btuart.c:1.28 Thu Aug 20 14:40:17 2015
+++ src/sys/dev/bluetooth/btuart.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: btuart.c,v 1.28 2015/08/20 14:40:17 christos Exp $ */
+/* $NetBSD: btuart.c,v 1.28.8.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 2006, 2007 KIYOHARA Takashi
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.28 2015/08/20 14:40:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.28.8.1 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -273,6 +273,7 @@ btuartopen(dev_t devno __unused, struct
splx(s);
+ device_release(dev);
return 0;
}
Index: src/sys/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.96.4.1 src/sys/dev/dkwedge/dk.c:1.96.4.2
--- src/sys/dev/dkwedge/dk.c:1.96.4.1 Thu Apr 27 05:36:35 2017
+++ src/sys/dev/dkwedge/dk.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.96.4.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: dk.c,v 1.96.4.2 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96.4.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96.4.2 2017/05/17 01:44:17 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -483,6 +483,7 @@ dkwedge_add(struct dkwedge_info *dkw)
sc->sc_size, sc->sc_offset,
sc->sc_ptype[0] == '\0' ? "<unknown>" : sc->sc_ptype);
+ device_release(sc->sc_dev);
return (0);
}
Index: src/sys/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.30 src/sys/dev/dm/dm_ioctl.c:1.30.8.1
--- src/sys/dev/dm/dm_ioctl.c:1.30 Sun May 10 14:08:54 2015
+++ src/sys/dev/dm/dm_ioctl.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.30 2015/05/10 14:08:54 christos Exp $ */
+/* $NetBSD: dm_ioctl.c,v 1.30.8.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -226,8 +226,10 @@ dm_dev_create_ioctl(prop_dictionary_t dm
aprint_error("Unable to attach pseudo device dm/%s\n", name);
return (ENOMEM);
}
- if ((dmv = dm_dev_alloc()) == NULL)
+ if ((dmv = dm_dev_alloc()) == NULL) {
+ device_release(devt);
return ENOMEM;
+ }
if (uuid)
strncpy(dmv->uuid, uuid, DM_UUID_LEN);
@@ -269,6 +271,7 @@ dm_dev_create_ioctl(prop_dictionary_t dm
/* Increment device counter After creating device */
atomic_inc_32(&dm_dev_counter);
+ device_release(devt);
return r;
}
/*
Index: src/sys/dev/gpio/gpiosim.c
diff -u src/sys/dev/gpio/gpiosim.c:1.20 src/sys/dev/gpio/gpiosim.c:1.20.4.1
--- src/sys/dev/gpio/gpiosim.c:1.20 Fri Jan 20 12:25:07 2017
+++ src/sys/dev/gpio/gpiosim.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiosim.c,v 1.20 2017/01/20 12:25:07 maya Exp $ */
+/* $NetBSD: gpiosim.c,v 1.20.4.1 2017/05/17 01:44:17 pgoyette Exp $ */
/* $OpenBSD: gpiosim.c,v 1.1 2008/11/23 18:46:49 mbalmer Exp $ */
/*
@@ -68,6 +68,7 @@ gpiosim_match(device_t parent, cfdata_t
void
gpiosimattach(int num __unused)
{
+ device_t dev;
cfdata_t cf;
int n, err;
@@ -81,7 +82,8 @@ gpiosimattach(int num __unused)
cf->cf_atname = "gpiosim";
cf->cf_unit = n;
cf->cf_fstate = FSTATE_NOTFOUND;
- config_attach_pseudo(cf);
+ dev = config_attach_pseudo(cf);
+ device_release(dev);
}
}
@@ -249,6 +251,7 @@ static int
gpiosim_modcmd(modcmd_t cmd, void *opaque)
{
#ifdef _MODULE
+ device_t dev;
int error = 0;
#endif
switch (cmd) {
@@ -275,7 +278,8 @@ gpiosim_modcmd(modcmd_t cmd, void *opaqu
gpiosim_cd.cd_name);
return error;
}
- config_attach_pseudo(gpiosim_cfdata);
+ dev = config_attach_pseudo(gpiosim_cfdata);
+ device_release(dev);
#endif
return 0;
case MODULE_CMD_FINI:
Index: src/sys/dev/hpc/hpf1275a_tty.c
diff -u src/sys/dev/hpc/hpf1275a_tty.c:1.27 src/sys/dev/hpc/hpf1275a_tty.c:1.27.24.1
--- src/sys/dev/hpc/hpf1275a_tty.c:1.27 Fri Jun 28 14:44:15 2013
+++ src/sys/dev/hpc/hpf1275a_tty.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: hpf1275a_tty.c,v 1.27 2013/06/28 14:44:15 christos Exp $ */
+/* $NetBSD: hpf1275a_tty.c,v 1.27.24.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* Copyright (c) 2004 Valeriy E. Ushakov
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpf1275a_tty.c,v 1.27 2013/06/28 14:44:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpf1275a_tty.c,v 1.27.24.1 2017/05/17 01:44:17 pgoyette Exp $");
#include "opt_wsdisplay_compat.h"
@@ -332,6 +332,7 @@ hpf1275a_open(dev_t dev, struct tty *tp)
sc->sc_tp = tp;
splx(s);
+ device_release(self);
return (0);
}
Index: src/sys/dev/ir/irframe_tty.c
diff -u src/sys/dev/ir/irframe_tty.c:1.61.8.1 src/sys/dev/ir/irframe_tty.c:1.61.8.2
--- src/sys/dev/ir/irframe_tty.c:1.61.8.1 Thu Apr 27 05:36:35 2017
+++ src/sys/dev/ir/irframe_tty.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: irframe_tty.c,v 1.61.8.1 2017/04/27 05:36:35 pgoyette Exp $ */
+/* $NetBSD: irframe_tty.c,v 1.61.8.2 2017/05/17 01:44:17 pgoyette Exp $ */
/*
* TODO
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.61.8.1 2017/04/27 05:36:35 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irframe_tty.c,v 1.61.8.2 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -322,6 +322,7 @@ irframetopen(dev_t dev, struct tty *tp)
splx(s);
+ device_release(d);
return (0);
}
Index: src/sys/dev/iscsi/iscsi_main.c
diff -u src/sys/dev/iscsi/iscsi_main.c:1.24 src/sys/dev/iscsi/iscsi_main.c:1.24.6.1
--- src/sys/dev/iscsi/iscsi_main.c:1.24 Sun Dec 25 06:55:28 2016
+++ src/sys/dev/iscsi/iscsi_main.c Wed May 17 01:44:17 2017
@@ -200,6 +200,7 @@ iscsi_match(device_t self, cfdata_t cfda
void
iscsiattach(int n)
{
+ device_t dev;
int err;
cfdata_t cf;
@@ -226,7 +227,8 @@ iscsiattach(int n)
cf->cf_unit = 0;
cf->cf_fstate = FSTATE_NOTFOUND;
- (void)config_attach_pseudo(cf);
+ dev = config_attach_pseudo(cf);
+ device_release(dev);
return;
}
@@ -660,6 +662,7 @@ static int
iscsi_modcmd(modcmd_t cmd, void *arg)
{
#ifdef _MODULE
+ device_t dev;
devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
int error;
static struct sysctllog *clog;
@@ -701,13 +704,14 @@ iscsi_modcmd(modcmd_t cmd, void *arg)
return error;
}
- if (config_attach_pseudo(iscsi_cfdata) == NULL) {
+ if ((dev = config_attach_pseudo(iscsi_cfdata)) == NULL) {
aprint_error("%s: config_attach_pseudo failed\n",
iscsi_cd.cd_name);
config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca);
config_cfdriver_detach(&iscsi_cd);
return ENXIO;
}
+ device_release(dev);
sysctl_iscsi_setup(&clog);
#endif
Index: src/sys/dev/nand/nandemulator.c
diff -u src/sys/dev/nand/nandemulator.c:1.7 src/sys/dev/nand/nandemulator.c:1.7.8.1
--- src/sys/dev/nand/nandemulator.c:1.7 Thu Aug 20 14:40:18 2015
+++ src/sys/dev/nand/nandemulator.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: nandemulator.c,v 1.7 2015/08/20 14:40:18 christos Exp $ */
+/* $NetBSD: nandemulator.c,v 1.7.8.1 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 2011 Department of Software Engineering,
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.7 2015/08/20 14:40:18 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.7.8.1 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -137,6 +137,7 @@ void
nandemulatorattach(int n)
{
int i, err;
+ device_t dev;
cfdata_t cf;
aprint_debug("nandemulator: requested %d units\n", n);
@@ -161,7 +162,8 @@ nandemulatorattach(int n)
cf->cf_unit = i;
cf->cf_fstate = FSTATE_STAR;
- (void)config_attach_pseudo(cf);
+ dev = config_attach_pseudo(cf);
+ device_release(dev);
}
}
@@ -754,6 +756,7 @@ static struct cfdata nandemulator_cfdata
static int
nandemulator_modcmd(modcmd_t cmd, void *arg)
{
+ device_t dev;
int error;
switch (cmd) {
@@ -784,7 +787,8 @@ nandemulator_modcmd(modcmd_t cmd, void *
return error;
}
- (void)config_attach_pseudo(nandemulator_cfdata);
+ dev = config_attach_pseudo(nandemulator_cfdata);
+ device_release(dev);
return 0;
Index: src/sys/dev/pad/pad.c
diff -u src/sys/dev/pad/pad.c:1.28.4.2 src/sys/dev/pad/pad.c:1.28.4.3
--- src/sys/dev/pad/pad.c:1.28.4.2 Sat Apr 29 11:12:14 2017
+++ src/sys/dev/pad/pad.c Wed May 17 01:44:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.28.4.2 2017/04/29 11:12:14 pgoyette Exp $ */
+/* $NetBSD: pad.c,v 1.28.4.3 2017/05/17 01:44:17 pgoyette Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.28.4.2 2017/04/29 11:12:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.28.4.3 2017/05/17 01:44:17 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -154,6 +154,7 @@ void
padattach(int n)
{
int i, err;
+ device_t dev;
cfdata_t cf;
aprint_debug("pad: requested %d units\n", n);
@@ -178,7 +179,8 @@ padattach(int n)
cf->cf_unit = i;
cf->cf_fstate = FSTATE_STAR;
- (void)config_attach_pseudo(cf);
+ dev = config_attach_pseudo(cf);
+ device_release(dev);
}
return;
@@ -740,6 +742,7 @@ static struct cfdata pad_cfdata[] = {
static int
pad_modcmd(modcmd_t cmd, void *arg)
{
+ device_t dev;
devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
int error;
@@ -784,7 +787,8 @@ pad_modcmd(modcmd_t cmd, void *arg)
return error;
}
- (void)config_attach_pseudo(pad_cfdata);
+ dev = config_attach_pseudo(pad_cfdata);
+ device_release(dev);
return 0;
case MODULE_CMD_FINI:
Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.349.4.2 src/sys/dev/raidframe/rf_netbsdkintf.c:1.349.4.3
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.349.4.2 Sat Apr 29 11:12:14 2017
+++ src/sys/dev/raidframe/rf_netbsdkintf.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.349.4.2 2017/04/29 11:12:14 pgoyette Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.349.4.3 2017/05/17 01:44:18 pgoyette Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.349.4.2 2017/04/29 11:12:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.349.4.3 2017/05/17 01:44:18 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -1866,6 +1866,7 @@ raidinit(struct raid_softc *rs)
rs->sc_flags |= RAIDF_INITED;
dkwedge_discover(&dksc->sc_dkdev);
+ device_release(dev);
}
#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
Index: src/sys/dev/sysmon/swwdog.c
diff -u src/sys/dev/sysmon/swwdog.c:1.19 src/sys/dev/sysmon/swwdog.c:1.19.8.1
--- src/sys/dev/sysmon/swwdog.c:1.19 Tue May 12 10:20:14 2015
+++ src/sys/dev/sysmon/swwdog.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $ */
+/* $NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $ */
/*
* Copyright (c) 2004, 2005 Steven M. Bellovin
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19 2015/05/12 10:20:14 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: swwdog.c,v 1.19.8.1 2017/05/17 01:44:18 pgoyette Exp $");
/*
*
@@ -145,6 +145,7 @@ swwdogattach(int n __unused)
workqueue_destroy(wq);
return 1;
}
+ device_release(dev);
return 0;
}
Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.252.4.3 src/sys/kern/subr_autoconf.c:1.252.4.4
--- src/sys/kern/subr_autoconf.c:1.252.4.3 Sun Apr 30 05:18:53 2017
+++ src/sys/kern/subr_autoconf.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.252.4.3 2017/04/30 05:18:53 pgoyette Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.252.4.4 2017/05/17 01:44:18 pgoyette Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.252.4.3 2017/04/30 05:18:53 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.252.4.4 2017/05/17 01:44:18 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1654,6 +1654,10 @@ config_attach(device_t parent, cfdata_t
* Note that because pseudo-devices are attached silently, any information
* the attach routine wishes to print should be prefixed with the device
* name by the attach routine.
+ *
+ * Also note that config_attach_pseudo() returns with a localcount
+ * reference held on the device_t. It is the caller's responsibility
+ * to release this reference.
*/
device_t
config_attach_pseudo(cfdata_t cf)
@@ -1677,6 +1681,9 @@ config_attach_pseudo(cfdata_t cf)
device_register(dev, NULL); /* like a root node */
#endif
+ /* Grab a reference to the device */
+ device_acquire(dev);
+
/* Let userland know */
devmon_report_device(dev, true);
Index: src/sys/modules/lua/lua.c
diff -u src/sys/modules/lua/lua.c:1.20.2.2 src/sys/modules/lua/lua.c:1.20.2.3
--- src/sys/modules/lua/lua.c:1.20.2.2 Sat Apr 29 10:19:32 2017
+++ src/sys/modules/lua/lua.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lua.c,v 1.20.2.2 2017/04/29 10:19:32 pgoyette Exp $ */
+/* $NetBSD: lua.c,v 1.20.2.3 2017/05/17 01:44:18 pgoyette Exp $ */
/*
* Copyright (c) 2014 by Lourival Vieira Neto <[email protected]>.
@@ -830,6 +830,7 @@ lua_modcmd(modcmd_t cmd, void *opaque)
{
#ifdef _MODULE
devmajor_t cmajor, bmajor;
+ device_t lua_dev;
int error = 0;
cmajor = bmajor = NODEVMAJOR;
@@ -867,7 +868,8 @@ lua_modcmd(modcmd_t cmd, void *opaque)
config_cfdriver_detach(&lua_cd);
return error;
}
- config_attach_pseudo(lua_cfdata);
+ lua_dev = config_attach_pseudo(lua_cfdata);
+ device_release(lua_dev);
#endif
return 0;
case MODULE_CMD_FINI:
Index: src/sys/net/if_etherip.c
diff -u src/sys/net/if_etherip.c:1.38 src/sys/net/if_etherip.c:1.38.8.1
--- src/sys/net/if_etherip.c:1.38 Mon Jul 11 11:31:51 2016
+++ src/sys/net/if_etherip.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if_etherip.c,v 1.38 2016/07/11 11:31:51 msaitoh Exp $ */
+/* $NetBSD: if_etherip.c,v 1.38.8.1 2017/05/17 01:44:18 pgoyette Exp $ */
/*
* Copyright (c) 2006, Hans Rosenfeld <[email protected]>
@@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.38 2016/07/11 11:31:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.38.8.1 2017/05/17 01:44:18 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -608,6 +608,7 @@ static int
etherip_clone_create(struct if_clone *ifc, int unit)
{
cfdata_t cf;
+ device_t dev;
cf = malloc(sizeof(struct cfdata), M_DEVBUF, M_WAITOK);
cf->cf_name = etherip_cd.cd_name;
@@ -615,11 +616,12 @@ etherip_clone_create(struct if_clone *if
cf->cf_unit = unit;
cf->cf_fstate = FSTATE_STAR;
- if (config_attach_pseudo(cf) == NULL) {
+ if ((dev = config_attach_pseudo(cf)) == NULL) {
aprint_error("%s%d: unable to attach an instance\n",
etherip_cd.cd_name, unit);
return (ENXIO);
}
+ device_release(dev);
return 0;
}
Index: src/sys/net/if_tap.c
diff -u src/sys/net/if_tap.c:1.99.4.1 src/sys/net/if_tap.c:1.99.4.2
--- src/sys/net/if_tap.c:1.99.4.1 Thu Apr 27 05:36:38 2017
+++ src/sys/net/if_tap.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tap.c,v 1.99.4.1 2017/04/27 05:36:38 pgoyette Exp $ */
+/* $NetBSD: if_tap.c,v 1.99.4.2 2017/05/17 01:44:18 pgoyette Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.99.4.1 2017/04/27 05:36:38 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.99.4.2 2017/05/17 01:44:18 pgoyette Exp $");
#if defined(_KERNEL_OPT)
@@ -652,12 +652,16 @@ tap_stop(struct ifnet *ifp, int disable)
static int
tap_clone_create(struct if_clone *ifc, int unit)
{
- if (tap_clone_creator(unit) == NULL) {
+ struct tap_softc *sc;
+
+ if ((sc = tap_clone_creator(unit)) == NULL) {
aprint_error("%s%d: unable to attach an instance\n",
tap_cd.cd_name, unit);
return ENXIO;
}
atomic_inc_uint(&tap_count);
+
+ device_release(sc->sc_dev);
return 0;
}
@@ -685,6 +689,8 @@ tap_clone_creator(int unit)
cf->cf_fstate = FSTATE_NOTFOUND;
}
+ /* Note that return occurs with a reference held! */
+
return device_private(config_attach_pseudo(cf));
}
@@ -783,6 +789,7 @@ tap_cdev_open(dev_t dev, int flags, int
static int
tap_dev_cloner(struct lwp *l)
{
+ int rv;
struct tap_softc *sc;
file_t *fp;
int error, fd;
@@ -797,8 +804,10 @@ tap_dev_cloner(struct lwp *l)
sc->sc_flags |= TAP_INUSE;
- return fd_clone(fp, fd, FREAD|FWRITE, &tap_fileops,
+ rv = fd_clone(fp, fd, FREAD|FWRITE, &tap_fileops,
(void *)(intptr_t)device_unit(sc->sc_dev));
+
+ device_release(sc->sc_dev);
}
/*
Index: src/sys/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.89.2.2 src/sys/opencrypto/cryptodev.c:1.89.2.3
--- src/sys/opencrypto/cryptodev.c:1.89.2.2 Sat Apr 29 11:12:15 2017
+++ src/sys/opencrypto/cryptodev.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptodev.c,v 1.89.2.2 2017/04/29 11:12:15 pgoyette Exp $ */
+/* $NetBSD: cryptodev.c,v 1.89.2.3 2017/05/17 01:44:18 pgoyette Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.89.2.2 2017/04/29 11:12:15 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.89.2.3 2017/05/17 01:44:18 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2157,6 +2157,7 @@ crypto_modcmd(modcmd_t cmd, void *arg)
{
int error = 0;
#ifdef _MODULE
+ device_t dev;
devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
#endif
@@ -2203,7 +2204,8 @@ crypto_modcmd(modcmd_t cmd, void *arg)
return error;
}
- (void)config_attach_pseudo(crypto_cfdata);
+ dev = config_attach_pseudo(crypto_cfdata);
+ device_release(dev);
#endif
return error;
Index: src/sys/opencrypto/cryptosoft.c
diff -u src/sys/opencrypto/cryptosoft.c:1.49 src/sys/opencrypto/cryptosoft.c:1.49.2.1
--- src/sys/opencrypto/cryptosoft.c:1.49 Tue Apr 18 17:05:05 2017
+++ src/sys/opencrypto/cryptosoft.c Wed May 17 01:44:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptosoft.c,v 1.49 2017/04/18 17:05:05 maya Exp $ */
+/* $NetBSD: cryptosoft.c,v 1.49.2.1 2017/05/17 01:44:18 pgoyette Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $ */
/* $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.49 2017/04/18 17:05:05 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.49.2.1 2017/05/17 01:44:18 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1388,6 +1388,7 @@ static int
swcrypto_modcmd(modcmd_t cmd, void *arg)
{
int error;
+ device_t dev;
switch (cmd) {
case MODULE_CMD_INIT:
@@ -1417,7 +1418,8 @@ swcrypto_modcmd(modcmd_t cmd, void *arg)
return error;
}
- (void)config_attach_pseudo(swcrypto_cfdata);
+ dev = config_attach_pseudo(swcrypto_cfdata);
+ device_release(dev);
return 0;
case MODULE_CMD_FINI: