Skip to contentSkip to conversation

atm: idt77252: Add missing `dma_map_error()`

PATCH Applied Thomas Fourier 3 participants 5 messages Jun 24, 2025 – Jun 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 atm: idt77252: Add missing `dma_map_error()`

The DMA map functions can fail and should be tested for errors.

---
 drivers/atm/idt77252.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/atm/idt77252.c +5 -0
index 1206ab764ba9..f2e91b7d79f0 100644
@@ -852,6 +852,8 @@ queue_skb(struct idt77252_dev *card, struct vc_map *vc,
 
 	IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data,
 						 skb->len, DMA_TO_DEVICE);
+	if (dma_mapping_error(&card->pcidev->dev, IDT77252_PRV_PADDR(skb)))
+		return -ENOMEM;
 
 	error = -EINVAL;
 
@@ -1857,6 +1859,8 @@ add_rx_skb(struct idt77252_dev *card, int queue,
 		paddr = dma_map_single(&card->pcidev->dev, skb->data,
 				       skb_end_pointer(skb) - skb->data,
 				       DMA_FROM_DEVICE);
+		if (dma_mapping_error(&card->pcidev->dev, paddr))
+			goto outpoolrm;
 		IDT77252_PRV_PADDR(skb) = paddr;
 
 		if (push_rx_skb(card, skb, queue)) {
@@ -1871,6 +1875,7 @@ add_rx_skb(struct idt77252_dev *card, int queue,
 	dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb),
 			 skb_end_pointer(skb) - skb->data, DMA_FROM_DEVICE);
 
+outpoolrm:
 	handle = IDT77252_PRV_POOL(skb);
 	card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL;
 
Signature · 1 line
2.43.0
reviewer
#1 lore raw
Quoted 30 lines · Thomas Fourier

The DMA map functions can fail and should be tested for errors.

---
 drivers/atm/idt77252.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/atm/idt77252.c +4 -0
index 1206ab764ba9..f2e91b7d79f0 100644
@@ -852,6 +852,8 @@ queue_skb(struct idt77252_dev *card, struct vc_map *vc,
 
 	IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data,
 						 skb->len, DMA_TO_DEVICE);
+	if (dma_mapping_error(&card->pcidev->dev, IDT77252_PRV_PADDR(skb)))
+		return -ENOMEM;
 
 	error = -EINVAL;
 
@@ -1857,6 +1859,8 @@ add_rx_skb(struct idt77252_dev *card, int queue,
 		paddr = dma_map_single(&card->pcidev->dev, skb->data,
 				       skb_end_pointer(skb) - skb->data,
 				       DMA_FROM_DEVICE);
+		if (dma_mapping_error(&card->pcidev->dev, paddr))
+			goto outpoolrm;
 		IDT77252_PRV_PADDR(skb) = paddr;
 
 		if (push_rx_skb(card, skb, queue)) {

drivers/atm/idt77252.c add_rx_skb(struct idt77252_dev *card, int queue, · line 1880

Quoted 6 lines
drivers/atm/idt77252.c +1 -0
@@ -1871,6 +1875,7 @@ add_rx_skb(struct idt77252_dev *card, int queue,
 	dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb),
 			 skb_end_pointer(skb) - skb->data, DMA_FROM_DEVICE);
 
+outpoolrm:
 	handle = IDT77252_PRV_POOL(skb);
 	card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL;

Hi Thomas,

Can sb_pool_remove() be used here?
It seems to be the converse of sb_pool_add(). And safer than the code above.
But perhaps I'm missing something.

#2 lore raw
Quoted 39 lines · Simon Horman
Quoted 30 lines · Thomas Fourier

The DMA map functions can fail and should be tested for errors.

---
  drivers/atm/idt77252.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/atm/idt77252.c +4 -0
index 1206ab764ba9..f2e91b7d79f0 100644
@@ -852,6 +852,8 @@ queue_skb(struct idt77252_dev *card, struct vc_map *vc,
 
  	IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data,
  						 skb->len, DMA_TO_DEVICE);
+	if (dma_mapping_error(&card->pcidev->dev, IDT77252_PRV_PADDR(skb)))
+		return -ENOMEM;
 
  	error = -EINVAL;
 
@@ -1857,6 +1859,8 @@ add_rx_skb(struct idt77252_dev *card, int queue,
  		paddr = dma_map_single(&card->pcidev->dev, skb->data,
  				       skb_end_pointer(skb) - skb->data,
  				       DMA_FROM_DEVICE);
+		if (dma_mapping_error(&card->pcidev->dev, paddr))
+			goto outpoolrm;
  		IDT77252_PRV_PADDR(skb) = paddr;
 
  		if (push_rx_skb(card, skb, queue)) {

drivers/atm/idt77252.c add_rx_skb(struct idt77252_dev *card, int queue, · line 1880

Quoted 6 lines
drivers/atm/idt77252.c +1 -0
@@ -1871,6 +1875,7 @@ add_rx_skb(struct idt77252_dev *card, int queue,
  	dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb),
  			 skb_end_pointer(skb) - skb->data, DMA_FROM_DEVICE);
 
+outpoolrm:
  	handle = IDT77252_PRV_POOL(skb);
  	card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL;

Hi Thomas,

Quoted 4 lines

Can sb_pool_remove() be used here?
It seems to be the converse of sb_pool_add(). And safer than the code above.
But perhaps I'm missing something.

Hi Simon,

I don't see any reason why this would be a problem,

though, I don't think it is related and the change should be in the same patch.

Should I create another patch for that?

reviewer Reviewed-by
#3 lore raw
Quoted 41 lines · Thomas Fourier
Quoted 34 lines · Simon Horman
Quoted 26 lines · Thomas Fourier

The DMA map functions can fail and should be tested for errors.

---
  drivers/atm/idt77252.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/atm/idt77252.c +4 -0
index 1206ab764ba9..f2e91b7d79f0 100644
@@ -852,6 +852,8 @@ queue_skb(struct idt77252_dev *card, struct vc_map *vc,
  	IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data,
  						 skb->len, DMA_TO_DEVICE);
+	if (dma_mapping_error(&card->pcidev->dev, IDT77252_PRV_PADDR(skb)))
+		return -ENOMEM;
  	error = -EINVAL;
@@ -1857,6 +1859,8 @@ add_rx_skb(struct idt77252_dev *card, int queue,
  		paddr = dma_map_single(&card->pcidev->dev, skb->data,
  				       skb_end_pointer(skb) - skb->data,
  				       DMA_FROM_DEVICE);
+		if (dma_mapping_error(&card->pcidev->dev, paddr))
+			goto outpoolrm;
  		IDT77252_PRV_PADDR(skb) = paddr;
  		if (push_rx_skb(card, skb, queue)) {

drivers/atm/idt77252.c add_rx_skb(struct idt77252_dev *card, int queue, · line 1879

Quoted 5 lines
drivers/atm/idt77252.c +1 -0
@@ -1871,6 +1875,7 @@ add_rx_skb(struct idt77252_dev *card, int queue,
  	dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb),
  			 skb_end_pointer(skb) - skb->data, DMA_FROM_DEVICE);
+outpoolrm:
  	handle = IDT77252_PRV_POOL(skb);
  	card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL;

Hi Thomas,

Quoted 4 lines

Can sb_pool_remove() be used here?
It seems to be the converse of sb_pool_add(). And safer than the code above.
But perhaps I'm missing something.

Quoted 6 lines

Hi Simon,

I don't see any reason why this would be a problem,

though, I don't think it is related and the change should be in the same patch.

Yes, good point. In that case this patch looks good to me.

Quoted 1 line

Should I create another patch for that?

I think that would be nice. But let's wait for this patch to land first.

#4 lore raw
In reply to Thomas Fourier
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 6 lines · On Tue, 24 Jun 2025 08:41:47 +0200 you wrote:

The DMA map functions can fail and should be tested for errors.

---
 drivers/atm/idt77252.c | 5 +++++
 1 file changed, 5 insertions(+)

Here is the summary with links:
- [v2] atm: idt77252: Add missing dma_map_error()

    https://git.kernel.org/netdev/net/c/c4890963350d

You are awesome, thank you!

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