From: Simon Horman <horms@kernel.org>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: Mark Einon <mark.einon@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] ethernet: et131x: Add missing check after DMA map
Date: Mon, 7 Jul 2025 21:01:43 +0100 [thread overview]
Message-ID: <20250707200143.GD452973@horms.kernel.org> (raw)
In-Reply-To: <20250707090955.69915-1-fourier.thomas@gmail.com>
On Mon, Jul 07, 2025 at 11:09:49AM +0200, Thomas Fourier wrote:
> The DMA map functions can fail and should be tested for errors.
> If the mapping fails, unmap and return an error.
>
> Fixes: 38df6492eb51 ("et131x: Add PCIe gigabit ethernet driver et131x to drivers/net")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
nits:
1) There are two spaces after "et131x:" in the subject.
One is enough.
2) I think you can drop "ethernet: " from the subject.
"et131x: " seems to be an appropriate prefix based on git history.
...
> @@ -2578,6 +2593,28 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
> &adapter->regs->global.watchdog_timer);
> }
> return 0;
> +
> +unmap_out:
> + // Unmap everything from i-1 to 1
> + while (--i) {
> + frag--;
> + dma_addr = desc[frag].addr_lo;
> + dma_addr |= (u64)desc[frag].addr_hi << 32;
> + dma_unmap_page(&adapter->pdev->dev, dma_addr,
> + desc[frag].len_vlan, DMA_TO_DEVICE);
> + }
I'm probably missing something obvious. But it seems to me that frag is
incremented iff a mapping is successful. So I think only the loop below is
needed.
> +
> +unmap_first_out:
> + // unmap header
> + while (frag--) {
> + frag--;
I don't think you want to decrement frag twice here.
> + dma_addr = desc[frag].addr_lo;
> + dma_addr |= (u64)desc[frag].addr_hi << 32;
> + dma_unmap_single(&adapter->pdev->dev, dma_addr,
> + desc[frag].len_vlan, DMA_TO_DEVICE);
> + }
> +
> + return -ENOMEM;
> }
>
> static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter)
--
pw-bot: changes-requested
next prev parent reply other threads:[~2025-07-07 20:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 9:09 [PATCH net] ethernet: et131x: Add missing check after DMA map Thomas Fourier
2025-07-07 20:01 ` Simon Horman [this message]
2025-07-08 7:13 ` Thomas Fourier
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=20250707200143.GD452973@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fourier.thomas@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.einon@gmail.com \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.