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 3AF1A2114; Tue, 23 Jan 2024 02:09:50 +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=1705975790; cv=none; b=ux662wgmsG0/BY3caHcN5j+8nuW+K1WddboeqEGOdTXzDMjSnY2Fnuq8QCdwLByO4uS6qiyfUCLPAGZwyqfXSm5Rm6GKGob7NHD+Lsmys8tsilW8CLimS8L3ozLKedeuncASQ1uBadnChAgTqRjiqfQ+PHOS+pX0zIAy3ehQDq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705975790; c=relaxed/simple; bh=zCzBOdUGeRoQWlLGi/br9hqXLcfWy9zCYE/v80qWm2Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QhxwbYSBi35lkps58NJ6M9i9akibYb0Mw146JWWP2mj7hh4LNfbI9cM2yDTxURSRMGf8Jr2Na0ZUuT2+F1uh7YcR0dfdRJHNCSrGzNKcz5itqwA1aqs4/h33J3To0w3S7z7yW1u3ZWUa2J1JYywNnrSkQrKZht9M8p+lm0fCXDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t2lJwJ3W; 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="t2lJwJ3W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F063CC43394; Tue, 23 Jan 2024 02:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705975790; bh=zCzBOdUGeRoQWlLGi/br9hqXLcfWy9zCYE/v80qWm2Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2lJwJ3WV/k+LzXx14VQgXRGdmee+kU0dXPYBLei5WD+b2wya6reE5hce+9s/PoBG QlTWYBtjOFUZHTuFwRs0wcAX8ypvh0AEmQSUPlyIG9wxyvpFX7NTDrR0un8rU3NHLJ LsRtaf5x6rv0OtsoJR4SEiCc6bsZa6t3EJNbNFdM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Yushchenko , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Sergey Shtylyov , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 6.6 547/583] net: ravb: Fix dma_addr_t truncation in error case Date: Mon, 22 Jan 2024 15:59:58 -0800 Message-ID: <20240122235828.878049694@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235812.238724226@linuxfoundation.org> References: <20240122235812.238724226@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Yushchenko [ Upstream commit e327b2372bc0f18c30433ac40be07741b59231c5 ] In ravb_start_xmit(), ravb driver uses u32 variable to store result of dma_map_single() call. Since ravb hardware has 32-bit address fields in descriptors, this works properly when mapping is successful - it is platform's job to provide mapping addresses that fit into hardware limitations. However, in failure case dma_map_single() returns DMA_MAPPING_ERROR constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant in u32 leads to truncation, and further call to dma_mapping_error() fails to notice the error. Fix that by storing result of dma_map_single() in a dma_addr_t variable. Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Signed-off-by: Nikita Yushchenko Reviewed-by: Niklas Söderlund Reviewed-by: Sergey Shtylyov Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/ravb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 3c2a6b23c202..8fec0dbbbe7b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1949,7 +1949,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev) struct ravb_tstamp_skb *ts_skb; struct ravb_tx_desc *desc; unsigned long flags; - u32 dma_addr; + dma_addr_t dma_addr; void *buffer; u32 entry; u32 len; -- 2.43.0