[Bug 273418] [panic] Repeating kernel panic on open(/dev/console)

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 21 Sep 2023 10:53:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273418

--- Comment #33 from Konstantin Belousov <kib@FreeBSD.org> ---
Yes, this is the usual problem with dev_clone handlers.

commit f041428f9d8aea9fe5a33c5c91ac31074d652672
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Thu Sep 21 13:47:14 2023 +0300

    tun/tap: correct ref count on cloned cdevs

    PR:     273418

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();
 }

-- 
You are receiving this mail because:
You are the assignee for the bug.