mirror of https://github.com/ipxe/ipxe.git
[efi] Avoid requesting zero-length DMA mappings
The UEFI specification does not prohibit zero-length DMA mappings. However, there is a reasonable chance that at least one implementation will treat it as an invalid parameter. As a precaution, avoid calling EFI_PCI_IO_PROTOCOL.Map() with a length of zero. Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/181/head
parent
a2e5cf1a3f
commit
a8442750e6
|
@ -352,15 +352,21 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map buffer */
|
/* Map buffer (if non-zero length) */
|
||||||
count = len;
|
count = len;
|
||||||
if ( ( efirc = pci_io->Map ( pci_io, op, phys_to_virt ( addr ), &count,
|
if ( len ) {
|
||||||
&bus, &mapping ) ) != 0 ) {
|
if ( ( efirc = pci_io->Map ( pci_io, op, phys_to_virt ( addr ),
|
||||||
|
&count, &bus, &mapping ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %08lx+%zx: %s\n",
|
DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %08lx+%zx: "
|
||||||
PCI_ARGS ( pci ), addr, len, strerror ( rc ) );
|
"%s\n", PCI_ARGS ( pci ), addr, len,
|
||||||
|
strerror ( rc ) );
|
||||||
goto err_map;
|
goto err_map;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
bus = addr;
|
||||||
|
mapping = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check that full length was mapped. The UEFI specification
|
/* Check that full length was mapped. The UEFI specification
|
||||||
* allows for multiple mappings to be required, but even the
|
* allows for multiple mappings to be required, but even the
|
||||||
|
@ -403,10 +409,8 @@ static void efipci_dma_unmap ( struct dma_device *dma,
|
||||||
container_of ( dma, struct efi_pci_device, pci.dma );
|
container_of ( dma, struct efi_pci_device, pci.dma );
|
||||||
EFI_PCI_IO_PROTOCOL *pci_io = efipci->io;
|
EFI_PCI_IO_PROTOCOL *pci_io = efipci->io;
|
||||||
|
|
||||||
/* Sanity check */
|
/* Unmap buffer (if non-zero length) */
|
||||||
assert ( map->token != NULL );
|
if ( map->token )
|
||||||
|
|
||||||
/* Unmap buffer */
|
|
||||||
pci_io->Unmap ( pci_io, map->token );
|
pci_io->Unmap ( pci_io, map->token );
|
||||||
|
|
||||||
/* Clear mapping */
|
/* Clear mapping */
|
||||||
|
|
Loading…
Reference in New Issue