linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()'
@ 2021-01-24  7:39 Christophe JAILLET
  2021-01-24 20:05 ` Markus Elfring
  2021-01-27 12:48 ` Miquel Raynal
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-01-24  7:39 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, vadivel.muruganx.ramuthevar,
	martin.blumenstingl
  Cc: kernel-janitors, Christophe JAILLET, linux-mtd, linux-kernel

If 'dmaengine_prep_slave_single()' fails, we must undo a previous
'dma_map_single()' call, as already done in all the other error handling
paths of this function.

Fixes: 0b1039f016e8 ("mtd: rawnand: Add NAND controller support on Intel LGM SoC")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mtd/nand/raw/intel-nand-controller.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c
index a304fda5d1fa..8b49fd56cf96 100644
--- a/drivers/mtd/nand/raw/intel-nand-controller.c
+++ b/drivers/mtd/nand/raw/intel-nand-controller.c
@@ -318,8 +318,10 @@ static int ebu_dma_start(struct ebu_nand_controller *ebu_host, u32 dir,
 	}
 
 	tx = dmaengine_prep_slave_single(chan, buf_dma, len, dir, flags);
-	if (!tx)
-		return -ENXIO;
+	if (!tx) {
+		ret = -ENXIO;
+		goto err_unmap;
+	}
 
 	tx->callback = callback;
 	tx->callback_param = ebu_host;
-- 
2.27.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()'
  2021-01-24  7:39 [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()' Christophe JAILLET
@ 2021-01-24 20:05 ` Markus Elfring
  2021-01-24 20:14   ` Richard Weinberger
  2021-01-27 12:48 ` Miquel Raynal
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2021-01-24 20:05 UTC (permalink / raw)
  To: Christophe Jaillet, linux-mtd
  Cc: Vignesh Raghavendra, Martin Blumenstingl, Richard Weinberger,
	kernel-janitors, linux-kernel, Ramuthevar Vadivel Murugan,
	Miquel Raynal

> If 'dmaengine_prep_slave_single()' fails, we must undo a previous
> 'dma_map_single()' call, as already done in all the other error handling
> paths of this function.

Would you ever like to use an imperative wording for the change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=fdbc80bdc4365078a0f7d65631171cb80e3ffd6e#n89> +++ b/drivers/mtd/nand/raw/intel-nand-controller.c
> @@ -318,8 +318,10 @@ static int ebu_dma_start(struct ebu_nand_controller *ebu_host, u32 dir,
>  	}
>
>  	tx = dmaengine_prep_slave_single(chan, buf_dma, len, dir, flags);
> -	if (!tx)
> -		return -ENXIO;
> +	if (!tx) {
> +		ret = -ENXIO;
> +		goto err_unmap;
> +	}
>
>  	tx->callback = callback;
…

By the way:
Can it be nicer to achieve the statement “ret = -EIO;” by a jump for
a target like “e_io” so that less exception handling code would be duplicated
for this function implementation?

Regards,
Markus

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()'
  2021-01-24 20:05 ` Markus Elfring
@ 2021-01-24 20:14   ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2021-01-24 20:14 UTC (permalink / raw)
  To: Christophe Jaillet
  Cc: Vignesh Raghavendra, Martin Blumenstingl, Richard Weinberger,
	kernel-janitors, LKML, Ramuthevar Vadivel Murugan, linux-mtd,
	Miquel Raynal

On Sun, Jan 24, 2021 at 9:13 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > If 'dmaengine_prep_slave_single()' fails, we must undo a previous
> > 'dma_map_single()' call, as already done in all the other error handling
> > paths of this function.
>
> Would you ever like to use an imperative wording for the change description?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=fdbc80bdc4365078a0f7d65631171cb80e3ffd6e#n89
>
>
> …
> > +++ b/drivers/mtd/nand/raw/intel-nand-controller.c
> > @@ -318,8 +318,10 @@ static int ebu_dma_start(struct ebu_nand_controller *ebu_host, u32 dir,
> >       }
> >
> >       tx = dmaengine_prep_slave_single(chan, buf_dma, len, dir, flags);
> > -     if (!tx)
> > -             return -ENXIO;
> > +     if (!tx) {
> > +             ret = -ENXIO;
> > +             goto err_unmap;
> > +     }
> >
> >       tx->callback = callback;
> …
>
> By the way:
> Can it be nicer to achieve the statement “ret = -EIO;” by a jump for
> a target like “e_io” so that less exception handling code would be duplicated
> for this function implementation?

Please feel free to ignore Markus.

https://lore.kernel.org/lkml/X+x3pIanr18Ep4ga@kroah.com/

-- 
Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()'
  2021-01-24  7:39 [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()' Christophe JAILLET
  2021-01-24 20:05 ` Markus Elfring
@ 2021-01-27 12:48 ` Miquel Raynal
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-01-27 12:48 UTC (permalink / raw)
  To: Christophe JAILLET, miquel.raynal, richard, vigneshr,
	vadivel.muruganx.ramuthevar, martin.blumenstingl
  Cc: linux-mtd, kernel-janitors, linux-kernel

On Sun, 2021-01-24 at 07:39:55 UTC, Christophe JAILLET wrote:
> If 'dmaengine_prep_slave_single()' fails, we must undo a previous
> 'dma_map_single()' call, as already done in all the other error handling
> paths of this function.
> 
> Fixes: 0b1039f016e8 ("mtd: rawnand: Add NAND controller support on Intel LGM SoC")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-27 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24  7:39 [PATCH] mtd: rawnand: Fix an error handling path in 'ebu_dma_start()' Christophe JAILLET
2021-01-24 20:05 ` Markus Elfring
2021-01-24 20:14   ` Richard Weinberger
2021-01-27 12:48 ` Miquel Raynal

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).