From patchwork Wed Jul 24 13:40:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13740960 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE3515957E; Wed, 24 Jul 2024 13:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721828451; cv=none; b=hWR0H7wTHJ8iTzXseUidQj0EefPr9+V73hUBUGCsvxbh2MqKEm+mqmfKLDZBkiDOK4Yz4vcY+i6mgh8JxuSjaD47eyVTGLXscUnIibxgWMV8tehJe8s9adxpU4NTvv5ysTl6UpbQfsAf5uEvla8+ImMC05swtp7XDkbn0lpRzYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721828451; c=relaxed/simple; bh=b8603IpDxvRUw2uI3q3aaa2Xvr94xBPfO4s7yfhoXoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OegtHlXX0FVVR6qhWtmc7+2xWzFpvv8aY31o9gTVCf78e8x+uGWU3FnygJu82DpfDGnRt84jMZU/mC1srKT5H0l/Ay9iE/DZyaqwDusFBFVGoB5BB44pSWyH/A6PYepzqRRRov825BbalnKZ7u/LN6+8A2ty3FKeebtU0I5exzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BB3F5irA; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="BB3F5irA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721828450; x=1753364450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b8603IpDxvRUw2uI3q3aaa2Xvr94xBPfO4s7yfhoXoE=; b=BB3F5irACSTxywBUogCmsIT3cMExSllDRQIdGX9Pjinv+H0SL+Eh3NgU nL2Zww+KW+nK6SpCwJ79IM/0z2hqr/9Ul+lgkgQuGSV+C8Xw7p6aUoLGb zTAthTrCbxuasBjaeVkrS5uRvYLhYj6NSXqIBsUOotmyN/XauwZFP9yHC VJv1DDFhAFc+pxoKHNnjztqHnrwrdVwA/V1I5Bq3vESj3X+Ufrlv6fifp 967ByP0jRE1YGbci+XmnBAIVooE2hrR3ZyUO5BDCZIAzUEuuEWsXVOhov bI38fWc9SRRD4y23iyRMXIwVCjs9SKm10zXNtoEJfiGJeaggFvKbjebUJ Q==; X-CSE-ConnectionGUID: iPXQahK7T5S88/ihFbRAvg== X-CSE-MsgGUID: lfchTMR3Sg6Di9JH2HdT/w== X-IronPort-AV: E=McAfee;i="6700,10204,11143"; a="19469384" X-IronPort-AV: E=Sophos;i="6.09,233,1716274800"; d="scan'208";a="19469384" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2024 06:40:49 -0700 X-CSE-ConnectionGUID: 2NzF0bjiSgq5iPU+HC6tig== X-CSE-MsgGUID: qsjIHC3ARWOd1OteqyrtJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,233,1716274800"; d="scan'208";a="52615658" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa009.jf.intel.com with ESMTP; 24 Jul 2024 06:40:46 -0700 From: Alexander Lobakin To: intel-wired-lan@lists.osuosl.org Cc: Alexander Lobakin , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , nex.sw.ncis.osdt.itp.upstreaming@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Kubiak , stable@vger.kernel.org, Pavan Kumar Linga Subject: [PATCH iwl-net 2/3] idpf: fix memleak in vport interrupt configuration Date: Wed, 24 Jul 2024 15:40:23 +0200 Message-ID: <20240724134024.2182959-3-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240724134024.2182959-1-aleksander.lobakin@intel.com> References: <20240724134024.2182959-1-aleksander.lobakin@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Michal Kubiak The initialization of vport interrupt consists of two functions: 1) idpf_vport_intr_init() where a generic configuration is done 2) idpf_vport_intr_req_irq() where the irq for each q_vector is requested. The first function used to create a base name for each interrupt using "kasprintf()" call. Unfortunately, although that call allocated memory for a text buffer, that memory was never released. Fix this by removing creating the interrupt base name in 1). Instead, always create a full interrupt name in the function 2), because there is no need to create a base name separately, considering that the function 2) is never called out of idpf_vport_intr_init() context. Fixes: d4d558718266 ("idpf: initialize interrupts and enable vport") Cc: stable@vger.kernel.org # 6.7 Signed-off-by: Michal Kubiak Reviewed-by: Pavan Kumar Linga Signed-off-by: Alexander Lobakin Reviewed-by: Simon Horman Tested-by: Krishneil Singh --- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c index af2879f03b8d..a2f9f252694a 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c @@ -3780,13 +3780,15 @@ void idpf_vport_intr_update_itr_ena_irq(struct idpf_q_vector *q_vector) /** * idpf_vport_intr_req_irq - get MSI-X vectors from the OS for the vport * @vport: main vport structure - * @basename: name for the vector */ -static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename) +static int idpf_vport_intr_req_irq(struct idpf_vport *vport) { struct idpf_adapter *adapter = vport->adapter; + const char *drv_name, *if_name, *vec_name; int vector, err, irq_num, vidx; - const char *vec_name; + + drv_name = dev_driver_string(&adapter->pdev->dev); + if_name = netdev_name(vport->netdev); for (vector = 0; vector < vport->num_q_vectors; vector++) { struct idpf_q_vector *q_vector = &vport->q_vectors[vector]; @@ -3804,8 +3806,8 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename) else continue; - name = kasprintf(GFP_KERNEL, "%s-%s-%d", basename, vec_name, - vidx); + name = kasprintf(GFP_KERNEL, "%s-%s-%s-%d", drv_name, if_name, + vec_name, vidx); err = request_irq(irq_num, idpf_vport_intr_clean_queues, 0, name, q_vector); @@ -4326,7 +4328,6 @@ int idpf_vport_intr_alloc(struct idpf_vport *vport) */ int idpf_vport_intr_init(struct idpf_vport *vport) { - char *int_name; int err; err = idpf_vport_intr_init_vec_idx(vport); @@ -4340,11 +4341,7 @@ int idpf_vport_intr_init(struct idpf_vport *vport) if (err) goto unroll_vectors_alloc; - int_name = kasprintf(GFP_KERNEL, "%s-%s", - dev_driver_string(&vport->adapter->pdev->dev), - vport->netdev->name); - - err = idpf_vport_intr_req_irq(vport, int_name); + err = idpf_vport_intr_req_irq(vport); if (err) goto unroll_vectors_alloc;