From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5A5D6283689; Wed, 23 Apr 2025 14:49:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745419750; cv=none; b=G7nA/bMevxpk9U0Lg4B3OBRQ0vMZ1D5EMxxO4d4KWrq2dakMsJ46J+A/O9PD7M16yMafh+EIbvCJE5RhQs1ZMdBLe23xsBUhKmK2KMpPz5oVwjXgZzbmWSfjE9EYyB+m8PevoEWuo8ax/f2uNUkS1hwFfgBbus/P42ZcUrjd7Aw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745419750; c=relaxed/simple; bh=iRYKpa8FRbxc4RRIKjD7jMBQV7FNyHKPB60cy8XT8es=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N8mdP5yXuUXOgDHJZ9L/Bah4yK0bnQrFhd8cXqHpVWK05GxjXjobJ0S54Duoi+VStb/8FK74QiJkHKaGaPpcjYmrg2PmtWhmcTrbfHGUs/UQhGXKt2AIewWzYubooWwBCx1O7MzfA1l1udXE3P80WeKpgLypezhPf9E+PpGyjkQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VDxLsDuz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VDxLsDuz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA7AC4CEE3; Wed, 23 Apr 2025 14:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745419750; bh=iRYKpa8FRbxc4RRIKjD7jMBQV7FNyHKPB60cy8XT8es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VDxLsDuzgqXOiiBMAgIjNHWuXQ6cD4Ze6kDh57SQz9Zm13V+Y1SfMF9QpCrah6h5W l1VKprbadImRjjIQecj3d5dDwIwIPEGDV8/M/HyeI+vm21+giFAc9TZ18nM8EYYura JcErac9SzNAubPZ150G3N1lj83BsrSQDKyIvr0KU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Abdun Nihaal , Simon Horman , Jacob Keller , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 055/223] cxgb4: fix memory leak in cxgb4_init_ethtool_filters() error path Date: Wed, 23 Apr 2025 16:42:07 +0200 Message-ID: <20250423142619.369869195@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142617.120834124@linuxfoundation.org> References: <20250423142617.120834124@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Abdun Nihaal [ Upstream commit 00ffb3724ce743578163f5ade2884374554ca021 ] In the for loop used to allocate the loc_array and bmap for each port, a memory leak is possible when the allocation for loc_array succeeds, but the allocation for bmap fails. This is because when the control flow goes to the label free_eth_finfo, only the allocations starting from (i-1)th iteration are freed. Fix that by freeing the loc_array in the bmap allocation error path. Fixes: d915c299f1da ("cxgb4: add skeleton for ethtool n-tuple filters") Signed-off-by: Abdun Nihaal Reviewed-by: Simon Horman Reviewed-by: Jacob Keller Link: https://patch.msgid.link/20250414170649.89156-1-abdun.nihaal@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c index 7f3f5afa864f4..1546c3db08f09 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c @@ -2270,6 +2270,7 @@ int cxgb4_init_ethtool_filters(struct adapter *adap) eth_filter->port[i].bmap = bitmap_zalloc(nentries, GFP_KERNEL); if (!eth_filter->port[i].bmap) { ret = -ENOMEM; + kvfree(eth_filter->port[i].loc_array); goto free_eth_finfo; } } -- 2.39.5