Article View: linux.kernel.netdev
Article #12510[PATCH 6.6.y] net: free_netdev: exit earlier if dummy
From: Dust Li
Date: Sat, 07 Nov 2026 16:14
Date: Sat, 07 Nov 2026 16:14
38 lines
9748 bytes
9748 bytes
From: Breno Leitao <leitao@debian.org>
For dummy devices, exit earlier at free_netdev() instead of executing
the whole function. This is necessary, because dummy devices are
special, and shouldn't have the second part of the function executed.
Otherwise reg_state, which is NETREG_DUMMY, will be overwritten and
there will be no way to identify that this is a dummy device. Also, this
device do not need the final put_device(), since dummy devices are not
registered (through register_netdevice()), where the device reference is
increased (at netdev_register_kobject()/device_add()).
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
---
net/core/dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index f9436563a2e84..0d88d285c713f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11093,7 +11093,8 @@ void free_netdev(struct net_device *dev)
dev->xdp_bulkq = NULL;
/* Compatibility with error handling in drivers */
- if (dev->reg_state == NETREG_UNINITIALIZED) {
+ if (dev->reg_state == NETREG_UNINITIALIZED ||
+ dev->reg_state == NETREG_DUMMY) {
netdev_freemem(dev);
return;
}
--
2.43.7
Technical Details
Message-ID:
<20261107161415.1917665-1-dust.li@linux.alibaba.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358424-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358424-linux-kernel-netdev=dewy.ru
From: dust.li@linux.alibaba.com (Dust Li)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 6.6.y] net: free_netdev: exit earlier if dummy
Date: Sun, 8 Nov 2026 00:14:15 +0800
Organization: Usenet Network
Message-ID: <20261107161415.1917665-1-dust.li@linux.alibaba.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="4141776"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:UHJ5gI398D1phU04KJ7e4yt8Ad8= sha256:UU0pt/QeDOx4yS6qGcbgZ72D/9t5jhG9rDcrlCB7PBU=
sha1:fQdx4BQlN8isl+5fRG1ORKPefwI= sha256:6yhZe6rFl96eUw2pEozw6fRp9+G77KFLO1j42lRSNLM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id C8AFC113459; Sat, 7 Nov 2026 19:37:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -10.55
X-Spam-Status: No, score=-10.55 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=linux.alibaba.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id SQ-1LvVeQnsZ;
Sat, 7 Nov 2026 19:36:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358424-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id DB4041132E6; Sat, 7 Nov 2026 19:36:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id CBB4DE3C99; Sat, 7 Nov 2026 16:15:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794068080;
b=jKc8wHZ90jgGT5gF3Cw6/lhhAXn3vaAGULOiFfmSHMYUsRN1Wz+331rTvkwm7yJ72TM7
m/5v17GlfZtPEyXKtT/trxtsqTI81dUbQBOkQTNXl9hjOkg4OzhlF41Mj4pNNHmDs9XhX
ZdFNB92exkOZP6CHAoSjwzmtGEdrq/4AZPnou4pANWY4OffKLVEbwjRnuydTKyaVklfY7
JHpeUvSD2XG7uKlBWDy4bmRIO1WEa7qzkGk++E0j7DV8yEDW/yuWxn3jx0fZdczbTn3AI
Ylb3x6IlFzyJpH6FedxMM9c/vVYle2DjdGKMMuBbjIvI6wGHU4VEKAGn8NlzNOpcpUQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794068080;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
X-Alimail-AntiSpam:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=91R0HJ+g+vL54XmNSHpf8yEC8LGciAL5mhbOTQZc/R4=;
b=26fy/u4ahmFEQe59Ob3btDZc/hwv+hQQM1Y7RbeReL+ObmduYrorMTMkYNaJKiIld27f
FD2QA+xQlo9mCKDsraSy95IcMZ5iF/klAq7mjz0X0yp2qknTZ9j2IvlQlgbDBHmLdO+qV
Lt/eJH/KdwCfnQhx6wMO2AZ+nazrb0p6Q5eFc7ib0nI5gOqYw2ZqP4uyuoEpfGvS/kz15
omy2GXXDUwTZSrHskDY6gSTEsGeQEpRmya3aMo0t7guwBrJhf9oBkZkuEka4MC46ulD6Y
WJi2NjGNRO7bdLqFEtH6pUBFyePwM1MoUSWg245ySW0wnMZqSoY2hZNNXr9WLs9czqw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=Fl1SpASj;
dmarc=pass header.from=linux.alibaba.com;
spf=pass smtp.mailfrom=linux.alibaba.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id AFC0D606AC2B;
Sat, 7 Nov 2026 16:14:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=Fl1SpASj
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.112
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794068079;
b=vCZDo2QGkrGHehiiIzu7/80pD2I8V+OJpwx0yC+oq3N3dWtICYRqnqEvn+x2ObR9oLhj
6TqG6n3PW55JI1fVMZ7ZO0DJVxRCINDGRIPcJ/1JH0IoMazvSjspESX159Bko2V+HLy2u
LeEUVkLRHXZV8J12EajI4Gil2C0/UbuBgyopeT7pvbj9/rhgE+zJL90lMBoHyQPN92UZr
F2IYkVIDRGbeUuPl5/VcNNJCtRioSF3BuxgZ2Mf5hWjIMO2ZthXJxcXo5sp4z7Kjuknkx
sk19BImXg9/1FJnZ8SC7my17IlrQbPIMP3XnNmgEiIvaznH8sxzhaSgHLwrZNs9fnzA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794068079;
h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc:
Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=91R0HJ+g+vL54XmNSHpf8yEC8LGciAL5mhbOTQZc/R4=;
b=gTZWrqATbayijt/ZFtUZsAFkbLzfcDa5K37BXZdgT0L538Er0WOit8vIfjapGKCVhi1d
kuLaS8GhU6un/Yy9bca84xVmkhsNFF0O5ScGcdrfOZoha4hQnroOArrJVf8eO2Kmw4i7D
J+GAten1oiHxPVSR67zHef+rofK3PTRh3I1dVq60pLejitRN/J3fXEnrEI4rxz99pllEI
qHG7Hjwjvds6KQzpCabN9Tzc6ehfhlEzS9dxnrZ7W3YzB6+nD6PTCsQCBo9HwmMYefcNS
0e6cZXuQrUt8b7GDPjd/bWJoC3hP57M4JD2mGvAT9miFJOu4TOSHb/scBHGo1v320AA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=linux.alibaba.com;
spf=pass smtp.mailfrom=linux.alibaba.com;
dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=Fl1SpASj;
arc=none smtp.remote-ip=115.124.30.112
X-Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEB9D606A32E;
Sat, 7 Nov 2026 16:14:35 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DEB9D606A32E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=linux.alibaba.com; s=default;
t=1794068068; h=From:To:Subject:Date:Message-ID:MIME-Version;
bh=91R0HJ+g+vL54XmNSHpf8yEC8LGciAL5mhbOTQZc/R4=;
b=Fl1SpASjdcJsdzbnH6npJkVk3bYvtMyX/+7cwa94OsiWFIBP6+IlxtZ9vQW2EcdAiSVrI143VyXyV98Gn03uM11KYwJwDS3nv+Ers32aWxCj+SvYJY/Yn8yWJ5+KGvMWtmXUW2r919LU7o0b5HaeHGCD2+buJ+rc4WIf3hWdc50=
X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=dust.li@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0XEEn.ju_1794068067;
X-Received: from localhost(mailfrom:dust.li@linux.alibaba.com fp:SMTPD_---0XEEn.ju_1794068067 cluster:ay36)
by smtp.aliyun-inc.com;
Sun, 08 Nov 2026 00:14:28 +0800
X-Cc: Breno Leitao <leitao@debian.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.53.0.apsara
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list