linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: stable@vger.kernel.org,  Richard Weinberger <richard@nod.at>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	 Wolfram Sang <wsa+renesas@sang-engineering.com>,
	 linux-mtd@lists.infradead.org,
	linux-renesas-soc@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: rawnand: renesas: Add missing check after DMA map
Date: Wed, 02 Jul 2025 09:48:07 +0200	[thread overview]
Message-ID: <878ql7nidk.fsf@bootlin.com> (raw)
In-Reply-To: <20250702071722.24921-3-fourier.thomas@gmail.com> (Thomas Fourier's message of "Wed, 2 Jul 2025 09:17:22 +0200")

Hi Thomas,

On 02/07/2025 at 09:17:22 +02, Thomas Fourier <fourier.thomas@gmail.com> wrote:

> The DMA map functions can fail and should be tested for errors.
>
> Fixes: d8701fe890ec ("mtd: rawnand: renesas: Add new NAND controller driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
>  drivers/mtd/nand/raw/renesas-nand-controller.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/renesas-nand-controller.c b/drivers/mtd/nand/raw/renesas-nand-controller.c
> index 44f6603736d1..f4a775571733 100644
> --- a/drivers/mtd/nand/raw/renesas-nand-controller.c
> +++ b/drivers/mtd/nand/raw/renesas-nand-controller.c
> @@ -426,6 +426,10 @@ static int rnandc_read_page_hw_ecc(struct nand_chip *chip, u8 *buf,
>  	/* Configure DMA */
>  	dma_addr = dma_map_single(rnandc->dev, rnandc->buf, mtd->writesize,
>  				  DMA_FROM_DEVICE);
> +	if (dma_mapping_error(rnandc->dev, dma_addr)) {
> +		dev_err(rnandc->dev, "DMA mapping failed.\n");

This error message is not informative, please drop
it. dma_mapping_error() does give more information if you enable some
DMA DEBUG Kconfig symbol already.

> +		return -ENOMEM;
> +	}
>  	writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
>  	writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
>  	writel(DMA_TLVL_MAX, rnandc->regs + DMA_TLVL_REG);
> @@ -606,6 +610,10 @@ static int rnandc_write_page_hw_ecc(struct nand_chip *chip, const u8 *buf,
>  	/* Configure DMA */
>  	dma_addr = dma_map_single(rnandc->dev, (void *)rnandc->buf, mtd->writesize,
>  				  DMA_TO_DEVICE);
> +	if (dma_mapping_error(rnandc->dev, dma_addr)) {
> +		dev_err(rnandc->dev, "DMA mapping failed.\n");

Ditto.

> +		return -ENOMEM;
> +	}
>  	writel(dma_addr, rnandc->regs + DMA_ADDR_LOW_REG);
>  	writel(mtd->writesize, rnandc->regs + DMA_CNT_REG);
>  	writel(DMA_TLVL_MAX, rnandc->regs + DMA_TLVL_REG);

Thanks,
Miquèl

      reply	other threads:[~2025-07-02  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02  7:17 [PATCH] mtd: rawnand: renesas: Add missing check after DMA map Thomas Fourier
2025-07-02  7:48 ` Miquel Raynal [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=878ql7nidk.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=fourier.thomas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=vigneshr@ti.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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).