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 92560253F3C; Wed, 5 Mar 2025 18:18:06 +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=1741198686; cv=none; b=IgNpvWIDlBr5MM51nnyX85VRroaJjpK+SJX91JP3gJXQioQx+2Vh0QPvJY+4H3HuvT7ErfxlIVZ31YzuzhqeasOfJiXtTXKwlePCJjB+CvvO05frUEo3W9XbWbjNkGts3EsiKx4xzs7ACSB/KhRDsp4ToKOUkwTkGLSg4ESYau0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741198686; c=relaxed/simple; bh=c17wcLg/LI5zC/nCFJrClfu2+P1tUkAcv9KtgBFjFYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JHsPCJz7qN3li2U3YBS1uuR/hsSmXNKyAyDmuL68CWxtRy4af0UfBas5jxS2eM3pKkqEEhs69AKxDFuDXvj2wDyBo6TI02Klw3FwxR/LEH+OMg5sP/FYtrcME0ZRu7nYxs/ndjbTthVmg0RZdFonT0+U73rViIfps+d2qKyES+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ybcK7/dk; 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="ybcK7/dk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF0E9C4CED1; Wed, 5 Mar 2025 18:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741198686; bh=c17wcLg/LI5zC/nCFJrClfu2+P1tUkAcv9KtgBFjFYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ybcK7/dkjQ/Q5eHc58aerYpqeBbF1sRXeZqF1dbPfwdTirl5BCly8vHrethoIKajS LJ/H67wry5Gw3Wy0LXg/n/TO3JdFYqZhLozORlzdpKmvDhKjl97Ml55SCwMRZc1GvW Mzzf8bPhy9LgfB8mqT+YSwUan2V0iXavjRD5t7sY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vladimir Oltean , Michal Swiatkowski , Wei Fang , Claudiu Manoil , Jakub Kicinski Subject: [PATCH 6.13 113/157] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Date: Wed, 5 Mar 2025 18:49:09 +0100 Message-ID: <20250305174509.854421132@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250305174505.268725418@linuxfoundation.org> References: <20250305174505.268725418@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.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wei Fang commit 39ab773e4c120f7f98d759415ccc2aca706bbc10 upstream. When a DMA mapping error occurs while processing skb frags, it will free one more tx_swbd than expected, so fix this off-by-one issue. Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers") Cc: stable@vger.kernel.org Suggested-by: Vladimir Oltean Suggested-by: Michal Swiatkowski Signed-off-by: Wei Fang Reviewed-by: Vladimir Oltean Reviewed-by: Claudiu Manoil Link: https://patch.msgid.link/20250224111251.1061098-2-wei.fang@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/enetc/enetc.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -146,6 +146,24 @@ static int enetc_ptp_parse(struct sk_buf return 0; } +/** + * enetc_unwind_tx_frame() - Unwind the DMA mappings of a multi-buffer Tx frame + * @tx_ring: Pointer to the Tx ring on which the buffer descriptors are located + * @count: Number of Tx buffer descriptors which need to be unmapped + * @i: Index of the last successfully mapped Tx buffer descriptor + */ +static void enetc_unwind_tx_frame(struct enetc_bdr *tx_ring, int count, int i) +{ + while (count--) { + struct enetc_tx_swbd *tx_swbd = &tx_ring->tx_swbd[i]; + + enetc_free_tx_frame(tx_ring, tx_swbd); + if (i == 0) + i = tx_ring->bd_count; + i--; + } +} + static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) { bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false; @@ -329,13 +347,7 @@ static int enetc_map_tx_buffs(struct ene dma_err: dev_err(tx_ring->dev, "DMA map error"); - do { - tx_swbd = &tx_ring->tx_swbd[i]; - enetc_free_tx_frame(tx_ring, tx_swbd); - if (i == 0) - i = tx_ring->bd_count; - i--; - } while (count--); + enetc_unwind_tx_frame(tx_ring, count, i); return 0; }