[PATCH] atm: idt77252: Add missing `dma_map_error()`

Thomas Fourier posted 1 patch 3 months, 3 weeks ago
There is a newer version of this series
drivers/atm/idt77252.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] atm: idt77252: Add missing `dma_map_error()`
Posted by Thomas Fourier 3 months, 3 weeks ago
The DMA map functions can fail and should be tested for errors.

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/atm/idt77252.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 1206ab764ba9..4217586a82d6 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -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 outfree;
 		IDT77252_PRV_PADDR(skb) = paddr;
 
 		if (push_rx_skb(card, skb, queue)) {
-- 
2.43.0
Re: [PATCH] atm: idt77252: Add missing `dma_map_error()`
Posted by Jakub Kicinski 3 months, 2 weeks ago
On Thu, 19 Jun 2025 12:57:06 +0200 Thomas Fourier wrote:
> @@ -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 outfree;
>  		IDT77252_PRV_PADDR(skb) = paddr;
>  
>  		if (push_rx_skb(card, skb, queue)) {

Hm, you're missing undoing sb_pool_add()

Like in another patch from you -- either jump to a new label in between 
the existing two which does the necessary unwind, or move the mapping
earlier, before we start adding the skb into the SW queue.
-- 
pw-bot: cr