git: 0365e5fc905b - main - if_tun: check device name

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 12 Dec 2023 04:02:37 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0365e5fc905b425313a0a2d89f0d8e2566924df2

commit 0365e5fc905b425313a0a2d89f0d8e2566924df2
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-12-12 00:13:59 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-12-12 04:02:11 +0000

    if_tun: check device name
    
    to avoid panic if the name already exists, which is possible with the
    interface renaming.
    
    PR:     266999
    Reviewed by:    kevans
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D43001
---
 sys/net/if_tuntap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c
index fccc666e2a00..4cb219dc92b6 100644
--- a/sys/net/if_tuntap.c
+++ b/sys/net/if_tuntap.c
@@ -820,7 +820,7 @@ tun_create_device(struct tuntap_driver *drv, int unit, struct ucred *cr,
 
 	make_dev_args_init(&args);
 	if (cr != NULL)
-		args.mda_flags = MAKEDEV_REF;
+		args.mda_flags = MAKEDEV_REF | MAKEDEV_CHECKNAME;
 	args.mda_devsw = &drv->cdevsw;
 	args.mda_cr = cr;
 	args.mda_uid = UID_UUCP;