Skip to contentSkip to conversation

net/sonic: use dma_mapping_error() for error check

PATCH Applied Finn Thain 3 participants 3 messages Mar 21, 2023 – Mar 22, 2023

Subsystems (3)
lore
Share & tools
lore

Finn Thain

author
#0 lore raw

PATCH v2 1/1 net/sonic: use dma_mapping_error() for error check

From: Zhang Changzhong <[email protected]>

The DMA address returned by dma_map_single() should be checked with dma_mapping_error(). Fix it accordingly.

Fixes efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update")

---
This was originally Zhang Changzhong's patch. I've just added the missing curly bracket which caused a build failure when the patch was first posted.

---
 drivers/net/ethernet/natsemi/sonic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/natsemi/sonic.c +2 -2
index d17d1b4f2585..825356ee3492 100644
@@ -292,7 +292,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
 	 */
 
 	laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE);
-	if (!laddr) {
+	if (dma_mapping_error(lp->device, laddr)) {
 		pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name);
 		dev_kfree_skb_any(skb);
 		return NETDEV_TX_OK;
@@ -509,7 +509,7 @@ static bool sonic_alloc_rb(struct net_device *dev, struct sonic_local *lp,
 
 	*new_addr = dma_map_single(lp->device, skb_put(*new_skb, SONIC_RBSIZE),
 				   SONIC_RBSIZE, DMA_FROM_DEVICE);
-	if (!*new_addr) {
+	if (dma_mapping_error(lp->device, *new_addr)) {
 		dev_kfree_skb(*new_skb);
 		*new_skb = NULL;
 		return false;
Signature · 1 line
2.37.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Finn Thain

From: Zhang Changzhong <[email protected]>

The DMA address returned by dma_map_single() should be checked with dma_mapping_error(). Fix it accordingly.

Fixes efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update")
Quoted 7 lines

---
This was originally Zhang Changzhong's patch. I've just added the missing curly bracket which caused a build failure when the patch was first posted.

---
 drivers/net/ethernet/natsemi/sonic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Thanks,

#2 lore raw
In reply to Finn Thain
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Tue, 21 Mar 2023 14:45:43 +1100 you wrote:

From: Zhang Changzhong <[email protected]>

The DMA address returned by dma_map_single() should be checked with dma_mapping_error(). Fix it accordingly.

Fixes efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update")

[...]

Here is the summary with links:
- [v2,net] net/sonic: use dma_mapping_error() for error check

    https://git.kernel.org/netdev/net/c/4107b8746d93

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html