linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atm: idt77252: Add missing `dma_map_error()`
@ 2025-06-19 10:57 Thomas Fourier
  2025-06-23 23:40 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2025-06-19 10:57 UTC (permalink / raw)
  Cc: Thomas Fourier, Chas Williams, moderated list:ATM, open list:ATM,
	open list

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] atm: idt77252: Add missing `dma_map_error()`
  2025-06-19 10:57 [PATCH] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
@ 2025-06-23 23:40 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-06-23 23:40 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: Chas Williams, moderated list:ATM, open list:ATM, open list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-23 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 10:57 [PATCH] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
2025-06-23 23:40 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).