Re: [PATCH net v2] nui: Fix dma_mapping_error() check
From: Simon Horman
Date: Mon Jun 30 2025 - 13:09:25 EST
On Mon, Jun 30, 2025 at 10:36:43AM +0200, Thomas Fourier wrote:
> dma_map_XXX() functions return values DMA_MAPPING_ERROR as error values
> which is often ~0. The error value should be tested with
> dma_mapping_error().
>
> This patch creates a new function in niu_ops to test if the mapping
> failed. The test is fixed in niu_rbr_add_page(), added in
> niu_start_xmit() and the successfully mapped pages are unmaped upon error.
>
> Fixes: ec2deec1f352 ("niu: Fix to check for dma mapping errors.")
I think it fixes a bit more than that.
But perhaps the above tag is sufficient.
> Signed-off-by: Thomas Fourier <fourier.thomas@xxxxxxxxx>
Overall this looks good to me, thanks for the update.
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>
> ---
> drivers/net/ethernet/sun/niu.c | 31 ++++++++++++++++++++++++++++++-
> drivers/net/ethernet/sun/niu.h | 4 ++++
> 2 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
...
> @@ -10019,6 +10042,11 @@ static void niu_phys_unmap_single(struct device *dev, u64 dma_address,
> /* Nothing to do. */
> }
>
> +static int niu_phys_mapping_error(struct device *dev, u64 dma_address)
> +{
> + return false;
No need to resend just because of this, but
from a type PoV this should probably be:
return 0;
> +}
> +
> static const struct niu_ops niu_phys_ops = {
> .alloc_coherent = niu_phys_alloc_coherent,
> .free_coherent = niu_phys_free_coherent,
...