From nobody Mon Oct 09 23:38:12 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S4FpF05czz4wk5L; Mon, 9 Oct 2023 23:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S4FpD6m0lz3bk5; Mon, 9 Oct 2023 23:38:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696894693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yEMPctILEv0yNkUKyY5YlFO3KvoL6KWrxecqom/1e7s=; b=Hhfxa+oeWuNfXODNT1/b08Evl9K8kLx95Qgri5EzEF+AZebqsQ/rB+U5bt19xHh0dVfM/4 cEBgHVuJVarhAd7dbJL8uq/CVUxGIRkOXC9RZ5zXdGYjjZLxnza2jkTTBeL6L5xDjBkus0 OFhfbF1ZQqjOMmT4le3a3CsoBP8xx8Njf7bF4xvAyzcGqdnM/tfkzZmthY0FGWXu5L+rha znnMNVbaBFPKmNtBiX+bupCAMtrGGLL2iaXPjbbPaDfBcqGn65pLyzjK8+lJMPI3+FJMiA nTNlBsgbNXbeC9lNs64Mc3NrXRxGT/boK5B1VvBHPsg5znrlxsSrFNIP2FehwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696894692; a=rsa-sha256; cv=none; b=aSzqUJ193RbhrUYIP36gxl5j3EQwHn2RLHL64BDBAPsYqgc0WqEY2zyUrsGOQlrCFG7+9C LA/QHyI4NwoqQ/EZJOWIjVDxjF9xVGVYm0rDoOTbQDI34Sq25hcz4rl5UC0tAkjh6tlKef GtB/hYO46rMmUK8Lj4+38eXFERXPcFR+ndgTokgJoMbZBJHqAXU1yKJop4izKp/6Wm9cTQ LXZM+MP07DiYNJjzKEnZGIv//qemgCLUQrqo3MarrUzbcXy6LUbD+YEvZlMgCLIYedm3wh f4RmH+rMN64VvkdC4f6R/I7qpiHpC6Js4BMeK8O4VbghL4IINg44+Lfhq1xSGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696894692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yEMPctILEv0yNkUKyY5YlFO3KvoL6KWrxecqom/1e7s=; b=K+qhnam93tLNUfZA+OziQbQvcEqrKHmpR36BP/ueAzG5qIi98Na6wdycbBaMdZDIqFnsqM nCnxMISksUcrLAaU8y5BoQsspmXQOS3ukS8xdpJb3BfTd2YdRNZ7DzaUhPQsCTJ5WOjKAD qA3IFnQC6+JmpZyVbUAwW/KFu8Wdqv/XX8/tosPYj5pXNcO7Kh35RaYrHhmj0Fbn9Xvifb XrTow7BhKbK0wTWV5eGPy+Yt0mpzbeU09uDwFnqE63vTHldb+ZEF+zHx/9gi5BTSRgID+7 QHBEVnxLw/NG9othvR7pLbvGUM4nQhxIoRwa6AXEcniLrHEqMk927pX8sUqmbQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S4FpD5qP2z1c5; Mon, 9 Oct 2023 23:38:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 399NcCnv006133; Mon, 9 Oct 2023 23:38:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 399NcCug006130; Mon, 9 Oct 2023 23:38:12 GMT (envelope-from git) Date: Mon, 9 Oct 2023 23:38:12 GMT Message-Id: <202310092338.399NcCug006130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 27f1ec0be24b - main - tun/tap: correct ref count on cloned cdevs List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 27f1ec0be24b45559793e486a4fa5a2e7fdadc17 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=27f1ec0be24b45559793e486a4fa5a2e7fdadc17 commit 27f1ec0be24b45559793e486a4fa5a2e7fdadc17 Author: Konstantin Belousov AuthorDate: 2023-09-21 10:47:14 +0000 Commit: Konstantin Belousov 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(); }