From: Simon Horman <horms@kernel.org>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
Chas Williams <3chas3@gmail.com>,
"moderated list:ATM" <linux-atm-general@lists.sourceforge.net>,
"open list:ATM" <netdev@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
Date: Tue, 24 Jun 2025 17:51:28 +0100 [thread overview]
Message-ID: <20250624165128.GA1562@horms.kernel.org> (raw)
In-Reply-To: <20250624064148.12815-3-fourier.thomas@gmail.com>
On Tue, Jun 24, 2025 at 08:41:47AM +0200, Thomas Fourier wrote:
> 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 | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
> index 1206ab764ba9..f2e91b7d79f0 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 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;
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.
next prev parent reply other threads:[~2025-06-24 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 6:41 [PATCH v2] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
2025-06-24 16:51 ` Simon Horman [this message]
2025-06-25 9:14 ` Thomas Fourier
2025-06-25 9:40 ` Simon Horman
2025-06-25 22:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250624165128.GA1562@horms.kernel.org \
--to=horms@kernel.org \
--cc=3chas3@gmail.com \
--cc=fourier.thomas@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-atm-general@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).