From: Simon Horman <horms@kernel.org>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: "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>,
"Jonathan Currier" <dullfire@yahoo.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Shuah Khan" <shuah@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] nui: Fix dma_mapping_error() check
Date: Fri, 27 Jun 2025 21:16:15 +0100 [thread overview]
Message-ID: <20250627201615.GH1776@horms.kernel.org> (raw)
In-Reply-To: <20250627144823.250224-2-fourier.thomas@gmail.com>
On Fri, Jun 27, 2025 at 04:48:19PM +0200, Thomas Fourier wrote:
> dma_map_XXX() functions return as error values DMA_MAPPING_ERROR which
> is often ~0. The error value should be tested with dma_mapping_error().
>
> Fixes: ec2deec1f352 ("niu: Fix to check for dma mapping errors.")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> drivers/net/ethernet/sun/niu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
> index ddca8fc7883e..11ff08373de4 100644
> --- a/drivers/net/ethernet/sun/niu.c
> +++ b/drivers/net/ethernet/sun/niu.c
> @@ -3336,7 +3336,7 @@ static int niu_rbr_add_page(struct niu *np, struct rx_ring_info *rp,
>
> addr = np->ops->map_page(np->device, page, 0,
> PAGE_SIZE, DMA_FROM_DEVICE);
> - if (!addr) {
> + if (dma_mapping_error(np->device, addr)) {
> __free_page(page);
> return -ENOMEM;
> }
Hi Thomas,
Looking over niu.c I see two implementations of the .map_page callback.
1. niu_pci_map_page is a trivial wrapper around dma_map_page.
And in that case your change looks good.
2. niu_phys_map_page, which looks like this:
static u64 niu_phys_map_page(struct device *dev, struct page *page,
unsigned long offset, size_t size,
enum dma_data_direction direction)
{
return page_to_phys(page) + offset;
}
In this case dma_mapping_error may well correctly detect (no) errors.
But it will call debug_dma_mapping_error(), which doesn't seem ideal.
prev parent reply other threads:[~2025-06-27 20:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 14:48 [PATCH net] nui: Fix dma_mapping_error() check Thomas Fourier
2025-06-27 20:16 ` Simon Horman [this message]
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=20250627201615.GH1776@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dullfire@yahoo.com \
--cc=edumazet@google.com \
--cc=fourier.thomas@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@baylibre.com \
--cc=willy@infradead.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 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.