git: e900c81ede85 - stable/13 - tun/tap: correct ref count on cloned cdevs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Oct 2023 07:17:41 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e900c81ede851f52ab50b541b9a6ef5fbc9bb919 commit e900c81ede851f52ab50b541b9a6ef5fbc9bb919 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-21 10:47:14 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-16 07:17:23 +0000 tun/tap: correct ref count on cloned cdevs PR: 273418 (cherry picked from commit 27f1ec0be24b45559793e486a4fa5a2e7fdadc17) --- sys/net/if_tuntap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index b81c2149a62f..756aa04482cb 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -541,6 +541,8 @@ tun_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) /* find any existing device, or allocate new unit number */ dev = NULL; i = clone_create(&drv->clones, &drv->cdevsw, &unit, &dev, 0); + if (i == 0) + dev_ref(dev); /* No preexisting struct cdev *, create one */ if (i != 0) i = tun_create_device(drv, unit, NULL, &dev, name); @@ -596,6 +598,8 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen, /* find any existing device, or allocate new unit number */ i = clone_create(&drv->clones, &drv->cdevsw, &u, dev, 0); + if (i == 0) + dev_ref(*dev); if (i) { if (append_unit) { namelen = snprintf(devname, sizeof(devname), "%s%d",