Skip to content

Commit daee4f4

Browse files
alanmikhak-at-sifiveLorenzo Pieralisi
authored andcommitted
PCI: endpoint: Cast the page number to phys_addr_t
Modify pci_epc_mem_alloc_addr() to cast the variable 'pageno' from type 'int' to 'phys_addr_t' before shifting left. This cast is needed to avoid treating bit 31 of 'pageno' as the sign bit which would otherwise get sign-extended to produce a negative value. When added to the base address of PCI memory space, the negative value would produce an invalid physical address which falls before the start of the PCI memory space. Signed-off-by: Alan Mikhak <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Kishon Vijay Abraham I <[email protected]>
1 parent 54ecb8f commit daee4f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pci/endpoint/pci-epc-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
134134
if (pageno < 0)
135135
return NULL;
136136

137-
*phys_addr = mem->phys_base + (pageno << page_shift);
137+
*phys_addr = mem->phys_base + ((phys_addr_t)pageno << page_shift);
138138
virt_addr = ioremap(*phys_addr, size);
139139
if (!virt_addr)
140140
bitmap_release_region(mem->bitmap, pageno, order);

0 commit comments

Comments
 (0)