linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: floppy: Add missing checks after DMA map
@ 2025-06-19 11:07 Thomas Fourier
  2025-06-20  7:44 ` Christophe Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Fourier @ 2025-06-19 11:07 UTC (permalink / raw)
  Cc: Thomas Fourier, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, linuxppc-dev, linux-kernel

The DMA map functions can fail and should be tested for errors.

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 arch/powerpc/include/asm/floppy.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/floppy.h b/arch/powerpc/include/asm/floppy.h
index f8ce178b43b7..df8ce2ae636d 100644
--- a/arch/powerpc/include/asm/floppy.h
+++ b/arch/powerpc/include/asm/floppy.h
@@ -144,9 +144,14 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
 		bus_addr = 0;
 	}
 
-	if (!bus_addr)	/* need to map it */
+	if (!bus_addr) {	/* need to map it */
 		bus_addr = dma_map_single(&isa_bridge_pcidev->dev, addr, size,
 					  dir);
+		if (dma_mapping_error(&isa_bridge_pcidev->dev, bus_addr)) {
+			bus_addr = 0;
+			return -ENOMEM;
+		}
+	}
 
 	/* remember this one as prev */
 	prev_addr = addr;
-- 
2.43.0


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

end of thread, other threads:[~2025-06-20  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-19 11:07 [PATCH] powerpc: floppy: Add missing checks after DMA map Thomas Fourier
2025-06-20  7:44 ` Christophe Leroy

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