Date: Mon, 9 Oct 2023 23:38:12 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 27f1ec0be24b - main - tun/tap: correct ref count on cloned cdevs Message-ID: <202310092338.399NcCug006130@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=27f1ec0be24b45559793e486a4fa5a2e7fdadc17 commit 27f1ec0be24b45559793e486a4fa5a2e7fdadc17 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-21 10:47:14 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-09 23:36:59 +0000 tun/tap: correct ref count on cloned cdevs Reported and tested by: eugen PR: 273418 Discussed with: jah, kevans Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42008 --- sys/net/if_tuntap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index f4dbf685fba6..a01bc11aa64c 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -548,6 +548,7 @@ tun_clone_create(struct if_clone *ifc, char *name, size_t len, if (i != 0) i = tun_create_device(drv, unit, NULL, &dev, name); if (i == 0) { + dev_ref(dev); tuncreate(dev); struct tuntap_softc *tp = dev->si_drv1; *ifpp = tp->tun_ifp; @@ -611,8 +612,10 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen, i = tun_create_device(drv, u, cred, dev, name); } - if (i == 0) + if (i == 0) { + dev_ref(*dev); if_clone_create(name, namelen, NULL); + } out: CURVNET_RESTORE(); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310092338.399NcCug006130>