From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 367EFC43458 for ; Mon, 6 Jul 2026 09:51:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E387540A48; Mon, 6 Jul 2026 09:51:15 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 71ZCWQNOnHJd; Mon, 6 Jul 2026 09:51:15 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1C3A940A50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1783331475; bh=BYBZhplRdudVjZ0tSfbfUivOx27YdDhCEs3BTVtXds4=; h=Date:To:Cc:References:From:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=4HvWkz0XhNo0IpusQp0sWGeFPuXtAu7rQ66KHiMu8rfE48y/GJL9OSRO3u/NP+c44 S7L1sY9/tM+2YssozEtmfzk+IHwJXpQscxXzK6GoK5gIGFbG5KuQL5uTiEeB4J/TtK 3Ih3jU4t0KVwwJEfZ5eN7Sv+9OyKiAYRtJ/SZA2DB9gCEnBYwM7K14IanAi0OZcbWg WajD6MmNxsjUSCRnQGwL+Sdzw70+mwgDkpVL8jgObDKyy4YoPsmU80KmIAlimbywEm foGCsHfLlbtevPYd6/QMlpf2aRw27ULsAS/AntamndZq0h03223x9FarKRKA76XRqY Ud/VRHt8dJqPA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 1C3A940A50; Mon, 6 Jul 2026 09:51:15 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id F1A71F2 for ; Mon, 6 Jul 2026 09:51:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CFF1A40142 for ; Mon, 6 Jul 2026 09:51:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Q4GhUb1s6Wa3 for ; Mon, 6 Jul 2026 09:51:12 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=198.175.65.21; helo=mgamail.intel.com; envelope-from=marcin.szycik@linux.intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org F042C400AE DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F042C400AE Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by smtp2.osuosl.org (Postfix) with ESMTPS id F042C400AE for ; Mon, 6 Jul 2026 09:51:11 +0000 (UTC) X-CSE-ConnectionGUID: tXHQIeHsQH+EK0qvmQAFRg== X-CSE-MsgGUID: Hq0xcaDsQGiE32478Ehvsw== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="83824465" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="83824465" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 02:51:11 -0700 X-CSE-ConnectionGUID: z9CLoUOsTy2VFlZjUx6WyQ== X-CSE-MsgGUID: w0LGO3M/SGmg5pUekZArgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="276884555" Received: from unknown (HELO [10.217.160.239]) ([10.217.160.239]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 02:51:08 -0700 Message-ID: Date: Mon, 6 Jul 2026 11:51:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: xuanqiang.luo@linux.dev, intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Nguyen , Przemek Kitszel , Andrew Lunn , Joshua Hay , Tatyana Nikolova , Xuanqiang Luo References: <20260703104132.47419-1-xuanqiang.luo@linux.dev> Content-Language: en-US From: Marcin Szycik In-Reply-To: <20260703104132.47419-1-xuanqiang.luo@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783331473; x=1814867473; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1cw2dtvKWTaAGRljDiJTLFfP1+KQjkYN/p7W+Z6InYo=; b=UAyoKqrczH8LX1VNgx3ZLfD65VLgfeuHxuuA253cnHNCnz7sq5Z4f1yl MitPolkHmNyzTrMQQ2zYxmIlj3yTYQr5ZvJvwFAPEjUXvK2/2VWuqfAO6 zpQPvGLPKCWRBKA103KADk/diipzg4OFqy3RtEdhJgmSDr6qPIwE0HfJk 3vvOchl/u+7EcUvs8NHlAI2MBN7/SAChHrE1FycgeF3qPKZvqLPW3miu7 nCdRjTYaP0FTr4C64zsJRiFXF9TfS0ClHltHz21tf+7xSXK9fJ59+79+3 fl6emBdE933xnyszu86//D003TXLSnCYxeWJ1n5W83wx/x5ezpkz2QQHK g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=none (p=none dis=none) header.from=linux.intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UAyoKqrc Subject: Re: [Intel-wired-lan] [PATCH iwl-net v1] idpf: fix lan_regs leak on core init failure X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On 03/07/2026 12:41, xuanqiang.luo@linux.dev wrote: > From: Xuanqiang Luo > > idpf_vc_core_init() gets the LAN memory region layout before mapping the > regions and allocating vport resources. Both layout paths allocate > hw->lan_regs, but later error paths return without freeing it. > > idpf_vc_core_deinit() does not cover these paths because it returns unless > IDPF_VC_CORE_INIT is set, and that bit is set only after core init > succeeds. > > Free hw->lan_regs on the post-allocation error paths and clear the > pointer and region count. > > Fixes: 6aa53e861c1a ("idpf: implement get LAN MMIO memory regions") > Signed-off-by: Xuanqiang Luo > --- > drivers/net/ethernet/intel/idpf/idpf_virtchnl.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > index be66f9b2e101c..da49bb7b7e671 100644 > --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c > @@ -3479,6 +3479,7 @@ static int idpf_vport_params_buf_alloc(struct idpf_adapter *adapter) > */ > int idpf_vc_core_init(struct idpf_adapter *adapter) > { > + struct idpf_hw *hw = &adapter->hw; > int task_delay = 30; > u16 num_max_vports; > int err = 0; > @@ -3550,15 +3551,18 @@ int idpf_vc_core_init(struct idpf_adapter *adapter) > if (err) { > dev_err(&adapter->pdev->dev, "Failed to map BAR0 region(s): %d\n", > err); > - return -ENOMEM; > + err = -ENOMEM; > + goto err_lan_regs; > } > > pci_sriov_set_totalvfs(adapter->pdev, idpf_get_max_vfs(adapter)); > num_max_vports = idpf_get_max_vports(adapter); > adapter->max_vports = num_max_vports; > adapter->vports = kzalloc_objs(*adapter->vports, num_max_vports); > - if (!adapter->vports) > - return -ENOMEM; > + if (!adapter->vports) { > + err = -ENOMEM; > + goto err_lan_regs; > + } > > if (!adapter->netdevs) { > adapter->netdevs = kzalloc_objs(struct net_device *, > @@ -3624,6 +3628,10 @@ int idpf_vc_core_init(struct idpf_adapter *adapter) > err_netdev_alloc: > kfree(adapter->vports); > adapter->vports = NULL; > +err_lan_regs: > + kfree(hw->lan_regs); > + hw->lan_regs = NULL; > + hw->num_lan_regs = 0; > return err; > > init_failed: Does this apply? struct idpf_hw was removed in 9f4334ac4a5a ("idpf: refactor idpf to use libie control queues") [1]. [1] https://lore.kernel.org/intel-wired-lan/20260608144127.2751230-10-larysa.zaremba@intel.com/ Thanks, Marcin