* [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
@ 2025-06-24 6:41 Thomas Fourier
2025-06-24 16:51 ` Simon Horman
2025-06-25 22:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Fourier @ 2025-06-24 6:41 UTC (permalink / raw)
Cc: Thomas Fourier, Jakub Kicinski, 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 | 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;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
2025-06-24 6:41 [PATCH v2] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
@ 2025-06-24 16:51 ` Simon Horman
2025-06-25 9:14 ` Thomas Fourier
2025-06-25 22:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2025-06-24 16:51 UTC (permalink / raw)
To: Thomas Fourier
Cc: Jakub Kicinski, Chas Williams, moderated list:ATM, open list:ATM,
open list
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
2025-06-24 16:51 ` Simon Horman
@ 2025-06-25 9:14 ` Thomas Fourier
2025-06-25 9:40 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Fourier @ 2025-06-25 9:14 UTC (permalink / raw)
To: Simon Horman
Cc: Jakub Kicinski, Chas Williams, moderated list:ATM, open list:ATM,
open list
On 24/06/2025 18:51, Simon Horman wrote:
> 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.
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?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
2025-06-25 9:14 ` Thomas Fourier
@ 2025-06-25 9:40 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-06-25 9:40 UTC (permalink / raw)
To: Thomas Fourier
Cc: Jakub Kicinski, Chas Williams, moderated list:ATM, open list:ATM,
open list
On Wed, Jun 25, 2025 at 11:14:56AM +0200, Thomas Fourier wrote:
> On 24/06/2025 18:51, Simon Horman wrote:
> > 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.
>
>
> 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.
Reviewed-by: Simon Horman <horms@kernel.org>
> Should I create another patch for that?
I think that would be nice. But let's wait for this patch to land first.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] atm: idt77252: Add missing `dma_map_error()`
2025-06-24 6:41 [PATCH v2] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
2025-06-24 16:51 ` Simon Horman
@ 2025-06-25 22:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-25 22:40 UTC (permalink / raw)
To: Thomas Fourier; +Cc: kuba, 3chas3, linux-atm-general, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 24 Jun 2025 08:41:47 +0200 you 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(+)
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-25 22:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 6:41 [PATCH v2] atm: idt77252: Add missing `dma_map_error()` Thomas Fourier
2025-06-24 16:51 ` Simon Horman
2025-06-25 9:14 ` Thomas Fourier
2025-06-25 9:40 ` Simon Horman
2025-06-25 22:40 ` patchwork-bot+netdevbpf
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).