fix a few missing return value checks in scsi
Subsystems (2)
Hi,
The attached patch adds a few error checks for the pci dma_mask setting routines, which after all can fail and thus need their return code checked.
Greetings,
Arjan van de Ven
drivers/scsi/aic7xxx/aic7xxx_osm.c renamed from drivers/scsi/aic7xxx/aic7xxx_osm.c.OLD +9 -3
@@ -1408,12 +1408,18 @@* our dma mask when doing allocations. */ if (ahc->dev_softc !=NULL ) -ahc_pci_set_dma_mask (ahc->dev_softc,0xFFFFFFFF ); +if (ahc_pci_set_dma_mask (ahc->dev_softc,0xFFFFFFFF )) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (ENODEV ); + } *vaddr =pci_alloc_consistent (ahc->dev_softc, dmat->maxsize, &map->bus_addr);if (ahc->dev_softc !=NULL ) -ahc_pci_set_dma_mask (ahc->dev_softc, - ahc->platform_data->hw_dma_mask); +if (ahc_pci_set_dma_mask (ahc->dev_softc, + ahc->platform_data->hw_dma_mask)) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (ENODEV ); + }#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */ /* * At least in 2.2.14, malloc is a slab allocator so all
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c renamed from drivers/scsi/aic7xxx/aic7xxx_osm_pci.c.OLD +4 -1
@@ -168,7 +168,10 @@ ahc->flags |=AHC_39BIT_ADDRESSING ; ahc->platform_data->hw_dma_mask = mask_39bit; }else { -ahc_pci_set_dma_mask (pdev,0xFFFFFFFF ); +if (ahc_pci_set_dma_mask (pdev,0xFFFFFFFF )) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (-ENODEV ); + } ahc->platform_data->hw_dma_mask =0xFFFFFFFF ; }#endif
drivers/scsi/aic7xxx/aic79xx_osm.c renamed from drivers/scsi/aic7xxx/aic79xx_osm.c.OLD +9 -3
@@ -1776,12 +1776,18 @@* our dma mask when doing allocations. */ if (ahd->dev_softc !=NULL ) -ahd_pci_set_dma_mask (ahd->dev_softc,0xFFFFFFFF ); +if (ahd_pci_set_dma_mask (ahd->dev_softc,0xFFFFFFFF )) { +printk (KERN_WARNING "aic79xx: No suitable DMA available.\n" ); +return (ENODEV ); + } *vaddr =pci_alloc_consistent (ahd->dev_softc, dmat->maxsize, &map->bus_addr);if (ahd->dev_softc !=NULL ) -ahd_pci_set_dma_mask (ahd->dev_softc, - ahd->platform_data->hw_dma_mask); +if (ahd_pci_set_dma_mask (ahd->dev_softc, + ahd->platform_data->hw_dma_mask)) { +printk (KERN_WARNING "aic79xx: No suitable DMA available.\n" ); +return (ENODEV ); + }#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */ /* * At least in 2.2.14, malloc is a slab allocator so all
Quoted 64 lines · Arjan van de Ven
Hi,
The attached patch adds a few error checks for the pci
dma_masksetting routines, which after all can fail and thus need their return code checked.Greetings,
Arjan van de Ven------------------------------------------------------------------------
drivers/scsi/aic7xxx/aic7xxx_osm.c renamed from drivers/scsi/aic7xxx/aic7xxx_osm.c.OLD +9
-3@@ -1408,12 +1408,18 @@* our dma mask when doing allocations. */ if (ahc->dev_softc !=NULL ) -ahc_pci_set_dma_mask (ahc->dev_softc,0xFFFFFFFF ); +if (ahc_pci_set_dma_mask (ahc->dev_softc,0xFFFFFFFF )) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (ENODEV ); + } *vaddr =pci_alloc_consistent (ahc->dev_softc, dmat->maxsize, &map->bus_addr);if (ahc->dev_softc !=NULL ) -ahc_pci_set_dma_mask (ahc->dev_softc, - ahc->platform_data->hw_dma_mask); +if (ahc_pci_set_dma_mask (ahc->dev_softc, + ahc->platform_data->hw_dma_mask)) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (ENODEV ); + }#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */ /* * At least in 2.2.14, malloc is a slab allocator so all drivers/scsi/aic7xxx/aic7xxx_osm_pci.c renamed from drivers/scsi/aic7xxx/aic7xxx_osm_pci.c.OLD +4
-1@@ -168,7 +168,10 @@ ahc->flags |=AHC_39BIT_ADDRESSING ; ahc->platform_data->hw_dma_mask = mask_39bit; }else { -ahc_pci_set_dma_mask (pdev,0xFFFFFFFF ); +if (ahc_pci_set_dma_mask (pdev,0xFFFFFFFF )) { +printk (KERN_WARNING "aic7xxx: No suitable DMA available.\n" ); +return (-ENODEV ); + } ahc->platform_data->hw_dma_mask =0xFFFFFFFF ; }#endif drivers/scsi/aic7xxx/aic79xx_osm.c renamed from drivers/scsi/aic7xxx/aic79xx_osm.c.OLD +4
-1@@ -1776,12 +1776,18 @@* our dma mask when doing allocations. */ if (ahd->dev_softc !=NULL ) -ahd_pci_set_dma_mask (ahd->dev_softc,0xFFFFFFFF ); +if (ahd_pci_set_dma_mask (ahd->dev_softc,0xFFFFFFFF )) { +printk (KERN_WARNING "aic79xx: No suitable DMA available.\n" ); +return (ENODEV ); + } *vaddr =pci_alloc_consistent (ahd->dev_softc, dmat->maxsize, &map->bus_addr);if (ahd->dev_softc !=NULL )
drivers/scsi/aic7xxx/aic79xx_osm.c line 1793
Quoted 10 lines
drivers/scsi/aic7xxx/aic79xx_osm.c renamed from drivers/scsi/aic7xxx/aic79xx_osm.c.OLD +5
-2-ahd_pci_set_dma_mask (ahd->dev_softc, - ahd->platform_data->hw_dma_mask); +if (ahd_pci_set_dma_mask (ahd->dev_softc, + ahd->platform_data->hw_dma_mask)) { +printk (KERN_WARNING "aic79xx: No suitable DMA available.\n" ); +return (ENODEV ); + }#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */ /* * At least in 2.2.14, malloc is a slab allocator so all
No offense to you personally, but this is a bunch of crap. aic7xxx needs to use the standard kernel APIs for pci_set_dma_mask and pci_set_consistent_dma_mask...
We don't need a wrapper for every kernel API function :(
Jeff
Quoted 7 lines · Jeff Garzik
No offense to you personally, but this is a bunch of crap. aic7xxx needs to use the standard kernel APIs for
pci_set_dma_maskandpci_set_consistent_dma_mask...We don't need a wrapper for every kernel API function :(
that's an entirely different argument that I entirely agree with....