Article View: linux.kernel.netdev
Article #10217Re: [PATCH v3 net 1/4] net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data
From: netdev-bot+sashiko
Date: Tue, 03 Nov 2026 10:18
Date: Tue, 03 Nov 2026 10:18
82 lines
10589 bytes
10589 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message does not give the real reason for one line of
the fix.
--
net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data
This patch fixes the error path in hns3_nic_alloc_vector_data() for when
devm_kcalloc() of priv->tqp_vector fails. The new path calls put_vector()
for every vector that get_vector() acquired, and resets priv->vector_num
to 0 before returning.
> Call put_vector() for every acquired vector before returning the
> error, and reset priv->vector_num to 0 to avoid a NULL deref in the
> subsequent hns3_nic_dealloc_vector_data(), which iterates
> priv->tqp_vector (still NULL after the kcalloc failure) using
> priv->vector_num.
[Severity: Low]
Is this the right reason for the priv->vector_num reset? As far as I can
tell, no path calls hns3_nic_dealloc_vector_data() after
hns3_nic_alloc_vector_data() fails.
In hns3_client_init(), the failure jumps to a label that comes after the
dealloc call:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:hns3_client_init() {
...
ret = hns3_nic_alloc_vector_data(priv);
if (ret) {
ret = -ENOMEM;
goto out_alloc_vector_data;
}
...
out_init_vector_data:
hns3_nic_dealloc_vector_data(priv);
out_alloc_vector_data:
...
}
hns3_reset_notify_init_enet() works the same way:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:hns3_reset_notify_init_enet() {
...
ret = hns3_nic_alloc_vector_data(priv);
if (ret)
goto err_put_ring;
...
err_dealloc_vector:
hns3_nic_dealloc_vector_data(priv);
err_put_ring:
...
}
hns3_client_uninit() and hns3_reset_notify_uninit_enet() both start with
test_and_clear_bit(HNS3_NIC_STATE_INITED, &priv->state). They bail out
before calling hns3_nic_dealloc_vector_data() if the bit is clear.
HNS3_NIC_STATE_INITED is only set once init succeeds, so it is still
clear after this failure. That means the NULL deref described above
cannot happen, with or without this patch.
The reset may still be useful for other code that indexes
priv->tqp_vector by priv->vector_num while the netdev stays alive after
a failed reset re-init. One example is hns3_dump_coal_info() in
hns3_debugfs.c:
for (i = 0; i < priv->vector_num; i++) {
tqp_vector = &priv->tqp_vector[i];
Should the commit message name the code that actually depends on
priv->vector_num being 0, rather than hns3_nic_dealloc_vector_data()?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261030095633.377289-1-shaojijie%40huawei.com
Technical Details
Message-ID:
<179370110586.488856.5999411563039166781@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355409-linux-kernel-netdev=dewy.ruReferences:
<20261030095633.377289-2-shaojijie@huawei.com>Show 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-355409-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v3 net 1/4] net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data Date: Tue, 03 Nov 2026 10:18:25 +0000 Organization: Usenet Network Message-ID: <179370110586.488856.5999411563039166781@kernel.org> References: <20261030095633.377289-2-shaojijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3144897"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:/sJXxc08teRC3Iackv6ayxCu07E= sha256:ABl1BaI2ItfBJBiiE3AGRGVsd/FQEI33Oodjkc0Pld8= sha1:e2qXn2lel5Ub3fp1XimITug2/gg= sha256:xBXhjt7VHyh8UMBt8tSKcCAbHlWkR8Bj3IgQcG1FZds= 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 588081127F6; Tue, 3 Nov 2026 13:44:40 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 9pg7aZZiEjGw; Tue, 3 Nov 2026 13:44:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355409-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 55A5B1127CC; Tue, 3 Nov 2026 13:44:29 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 94FCC613A22; Tue, 3 Nov 2026 10:23:18 +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=1793701113; b=e0AAcUEJn+mn+x918lLeV9HvUTSHdHIcHW6PTI6y6s6FMCW9rdeoj8rwfxBPm5+z/VTl bP84cHNELIlKKt1mofZd40EOWT2vovyuKYISzHHz+PqF3FbGJ7RSgkLcK1nlL6PtCzFQd AvUzTbPFXS+sTn6WMilrwyf01Cnzo2a5gMtwt9FH0ppSpGvL2tNLrWNVv34qzRiGNgB8I oQDgcDvg0XtDJVplfmhNSsMlpMgm0FzO65wsqZ5rdnvfaJM7jkkpOZ7sgisVZD7YKZB3H icDkaDNxUFqxag5Z2wtRLz2wkdYRrdoDz5EPBzpRN9TkVeSNTqFk5I83B3lMWxE4r1Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793701113; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=q+qf7PzOxjIGrYfKn/FHezKWAiuMsA1N8qY4avTZ+sg=; b=X41r2Rmyx+wtyJCuZT4RsOqtN2OK+21tSWqJSHt6q1JmJx9Ew+Q/uE6wdvi//aVjE0mD rZdjM8BjDMng+Y8aptxrvtTxE8F7HEWqdU/Y/qVq6gIq++QsxS0iqQ8yFZiaxIaWoUCgX MQzQ7ZX0CxT66WYIkundetYwtVc9bMRJWRpOFx3xZPMieRmSP+YRPIBdVqNcp114C1ajC fbw6zaHiNZslye0H+zOWmZCN37E8JkYiOEYlkXGweBBZms3RPbBDSfWgVPyaRfL9D4yH8 JT9akE3FLW1gfa6n6I6OCNbP1WeFxgJvFeDT9dnL6hFqjxeWL5h527okiUglz/4CO9w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Js/t+wic"; 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 34C6B6082BE5; Tue, 3 Nov 2026 10:18:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Js/t+wic X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793701107; b=q7rcjRa4oKJjcY+2ucj0sOnlLkERiINGEhI98k12Etuv0WCZxucVG+/WrBrbt25vR1Gd fv5+VoPPbS7aPn0XW27zMvEEWhtZYy4ELznoov7px1ri3RADkkSCwU1ZE7rX7ewD+mvOM X/YanWzAUcRodMsaDIJIRc2VVplv2lI/02WBmuV3MirvoWL+fK3ZzhVYFZPUVp6KmLgjT znl2sD5R9QqqEPsjWd58W26ylqs+GP++kEo7rIw3PX38RZ2+xbM8a9A2CR+aFLJHg99rB RaYACE2pA5jADyw44L9uLgQ5plJXNnqcHZwIVb1rldZvREBtOe75QDa2OR/CfMRBr+w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793701107; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=q+qf7PzOxjIGrYfKn/FHezKWAiuMsA1N8qY4avTZ+sg=; b=SgVAH6QSAdNNy5DE49hmSqOP/FCzfK1U1OU0eyQatfEjqJyJ4a2NUmPIt2+dyUM20kJp JrOCREaKlVlsaegB7kL/WOXdVMUHpHsgMHs/YhjG1T0zz4axolKG2f5ygJisctgSiW9uW FveLpIK2sRbftKcz9dMeXNHhqMz4gbqFgCTi+eIF+wzdlwVvsdzv3GLEF7HXOtgDDqfJv 1DDTHJ5ytaeTbt+L2CExlhqT1CvFVmqIemZ5ZCKLEqxqAubfOAMXq9nAcEhi7Hi6hUx/+ /nrdeSgfIpmQgS0Sd6NpHRhduXfFlsNW2RVjcvCszrgbB2oHQjb4xejKHB/urrwbKqQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Js/t+wic"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19F20606EE8D; Tue, 3 Nov 2026 10:18:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EF7C1F00A02; Tue, 3 Nov 2026 10:18:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793701107; bh=q+qf7PzOxjIGrYfKn/FHezKWAiuMsA1N8qY4avTZ+sg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Js/t+wic0TSn5fTLXxZlAewrwiJJ9OtCg/7OOz8p6rErFOEu9Jg+aEmclGkaNai5D OrElr9bCrj5mXtAv/UjhtyfGYiRMyLldLI1AzzKYC+UnlLspBU7P6YFNjPssJtVKji +tmGSLDTg9Vrh+uYF7FAznbRESP53FRE2mTWJFd/8/0VmI1ATdC4SUD4ACxRkpVZKL KnmOoAb14UWgaNg4lghmItZpo8V8jOsWLQJVpfM3OkxUA3ondDmBrbepJTmTrJZ2j0 8ncLU+/at2PB21FjJnl5hr0YKSm7hE7TgWO8+TSphHIZEcPLBF1+UH2XxowjEJJ/Yd UmiqJ7Dxo/3ZA== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, shenjian15@huawei.com, liuyonglong@huawei.com, chenhao418@huawei.com, yangshuaisong@h-partners.com, ningwei15@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261030095633.377289-2-shaojijie@huawei.com> X-sashiko-severity: Low 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