diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index 6b0742527948..b60c805f6892 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -1035,6 +1035,7 @@ targclone(void *arg, char *name, int namelen, struct cdev **dev) return; *dev = make_dev(&targ_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600, "targ%d", u); + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; } diff --git a/sys/coda/coda_fbsd.c b/sys/coda/coda_fbsd.c index d68b63fb83ea..ac6ad48e8599 100644 --- a/sys/coda/coda_fbsd.c +++ b/sys/coda/coda_fbsd.c @@ -120,6 +120,7 @@ static void coda_fbsd_clone(arg, name, namelen, dev) return; *dev = make_dev(&codadevsw,unit2minor(u),UID_ROOT,GID_WHEEL,0600,"cfs%d",u); + dev_ref(*dev); mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO); LIST_INSERT_HEAD(&coda_mnttbl, mnt, mi_list); } diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c index 79c74af9fe84..ecd56c414c6d 100644 --- a/sys/dev/firewire/fwdev.c +++ b/sys/dev/firewire/fwdev.c @@ -875,6 +875,7 @@ fwdev_clone(void *arg, char *name, int namelen, struct cdev **dev) *dev = make_dev(&firewire_cdevsw, MAKEMINOR(devflag[i], unit, sub), UID_ROOT, GID_OPERATOR, 0660, "%s%d.%d", devnames[i], unit, sub); + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; dev_depends(sc->dev, *dev); return; diff --git a/sys/dev/nmdm/nmdm.c b/sys/dev/nmdm/nmdm.c index cd3b5f372b5a..e61a05f5fa0f 100644 --- a/sys/dev/nmdm/nmdm.c +++ b/sys/dev/nmdm/nmdm.c @@ -147,6 +147,7 @@ nmdm_clone(void *arg, char *name, int nameen, struct cdev **dev) *dev = d1->si_drv2; else *dev = d1; + dev_ref(*dev); } static void diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index bd4bcac7375c..8be2b199e8b8 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -643,8 +643,10 @@ snp_clone(arg, name, namelen, dev) if (i) *dev = make_dev(&snp_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600, "snp%d", u); - if (*dev != NULL) + if (*dev != NULL) { + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; + } } static int diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 5d3aa5256e74..689bec609e30 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -1174,6 +1174,7 @@ dsp_clone(void *arg, char *name, int namelen, struct cdev **dev) if ((pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) { *dev = pdev; + dev_ref(*dev); return; } } diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 58468477af41..9feccf64ea45 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -494,8 +494,10 @@ mixer_clone(void *arg, char *name, int namelen, struct cdev **dev) return; if (strcmp(name, "mixer") == 0) { sd = devclass_get_softc(pcm_devclass, snd_unit); - if (sd != NULL) + if (sd != NULL) { *dev = sd->mixer_dev; + dev_ref(*dev); + } } } diff --git a/sys/dev/vkbd/vkbd.c b/sys/dev/vkbd/vkbd.c index 57a40eddf7c1..a02dd3ad03af 100644 --- a/sys/dev/vkbd/vkbd.c +++ b/sys/dev/vkbd/vkbd.c @@ -168,8 +168,10 @@ vkbd_dev_clone(void *arg, char *name, int namelen, struct cdev **dev) if (clone_create(&vkbd_dev_clones, &vkbd_dev_cdevsw, &unit, dev, 0)) { *dev = make_dev(&vkbd_dev_cdevsw, unit2minor(unit), UID_ROOT, GID_WHEEL, 0600, DEVICE_NAME "%d", unit); - if (*dev != NULL) + if (*dev != NULL) { + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; + } } } diff --git a/sys/fs/coda/coda_fbsd.c b/sys/fs/coda/coda_fbsd.c index d68b63fb83ea..ac6ad48e8599 100644 --- a/sys/fs/coda/coda_fbsd.c +++ b/sys/fs/coda/coda_fbsd.c @@ -120,6 +120,7 @@ static void coda_fbsd_clone(arg, name, namelen, dev) return; *dev = make_dev(&codadevsw,unit2minor(u),UID_ROOT,GID_WHEEL,0600,"cfs%d",u); + dev_ref(*dev); mnt = malloc(sizeof(struct coda_mntinfo), M_CODA, M_WAITOK|M_ZERO); LIST_INSERT_HEAD(&coda_mnttbl, mnt, mi_list); } diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 8c100effa319..90139c2272ee 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -655,6 +655,7 @@ devfs_lookupx(ap) devfs_populate(dmp); dde = devfs_itode(dmp, cdev->si_inode); + dev_rel(cdev); if (dde == NULL || *dde == NULL || *dde == DE_DELETED) goto notfound; diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 21d47e27a845..3a53294a735d 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -710,6 +710,7 @@ pty_clone(void *arg, char *name, int namelen, struct cdev **dev) return; *dev = make_dev(&ptc_cdevsw, u, UID_ROOT, GID_WHEEL, 0666, "pty%c%r", names[u / 32], u % 32); + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; return; } diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index c813211ee8ed..8951e99b263b 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -65,6 +65,7 @@ ctty_clone(void *arg, char *name, int namelen, struct cdev **dev) *dev = ctty; else *dev = curthread->td_proc->p_session->s_ttyvp->v_rdev; + dev_ref(*dev); } static void diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 7708504b31a1..3cce6e8871c1 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1605,6 +1605,7 @@ bpf_clone(arg, name, namelen, dev) return; *dev = make_dev(&bpf_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600, "bpf%d", u); + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; return; } diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 46fd2762fadf..601b95d73023 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -253,8 +253,10 @@ tapclone(arg, name, namelen, dev) if (i) { *dev = make_dev(&tap_cdevsw, unit2minor(unit | extra), UID_ROOT, GID_WHEEL, 0600, "%s%d", device_name, unit); - if (*dev != NULL) + if (*dev != NULL) { + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; + } } } /* tapclone */ diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 8936110ee8e0..6fe7b10c96b3 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -155,8 +155,10 @@ tunclone(void *arg, char *name, int namelen, struct cdev **dev) /* No preexisting struct cdev *, create one */ *dev = make_dev(&tun_cdevsw, unit2minor(u), UID_UUCP, GID_DIALER, 0600, "tun%d", u); - if (*dev != NULL) + if (*dev != NULL) { + dev_ref(*dev); (*dev)->si_flags |= SI_CHEAPCLONE; + } } } diff --git a/sys/netsmb/smb_dev.c b/sys/netsmb/smb_dev.c index 5a3dbf70a40c..89a167666ca2 100644 --- a/sys/netsmb/smb_dev.c +++ b/sys/netsmb/smb_dev.c @@ -109,6 +109,7 @@ nsmb_dev_clone(void *arg, char *name, int namelen, struct cdev **dev) return; *dev = make_dev(&nsmb_cdevsw, unit2minor(u), 0, 0, 0600, NSMB_NAME"%d", u); + dev_ref(*dev); } static int