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

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 22 Sep 2023 03:37:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273418

--- Comment #37 from Konstantin Belousov <kib@FreeBSD.org> ---
devfs consumer is same. There was a trivial conflict. Below is the stable/13'
equivalent.

commit e84128814bcdc854c1670447ba1525711736d7f9
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

    (cherry picked from commit 07fda41d2a2df0d0d422f30a8a2353de5f0d9c3e)

diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index b81c2149a62f..bad09a3148b9 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -544,8 +544,10 @@ tun_clone_create(struct if_clone *ifc, char *name, size_t
len, caddr_t params)
        /* No preexisting struct cdev *, create one */
        if (i != 0)
                i = tun_create_device(drv, unit, NULL, &dev, name);
-       if (i == 0)
+       if (i == 0) {
+               dev_ref(dev);
                tuncreate(dev);
+       }

        return (i);
 }
@@ -605,8 +607,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.