arch/powerpc/include/asm/floppy.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
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
Hi Thomas, Le 19/06/2025 à 13:07, Thomas Fourier a écrit : > [Vous ne recevez pas souvent de courriers de fourier.thomas@gmail.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > 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; bus_addr is a local variable, there is no point in setting it to zero here. Just return -ENOMEM. > + return -ENOMEM; > + } > + } > > /* remember this one as prev */ > prev_addr = addr; > -- > 2.43.0 >
© 2016 - 2025 Red Hat, Inc.