Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pci/controller/cadence'

- Fix cdns_pcie_host_dma_ranges_cmp() to prevent possible invalid sort
order (Ian Rogers)

* pci/controller/cadence:
PCI: cadence: Avoid signed 64-bit truncation and invalid sort

+11 -1
+11 -1
drivers/pci/controller/cadence/pcie-cadence-host-common.c
··· 173 173 const struct list_head *b) 174 174 { 175 175 struct resource_entry *entry1, *entry2; 176 + u64 size1, size2; 176 177 177 178 entry1 = container_of(a, struct resource_entry, node); 178 179 entry2 = container_of(b, struct resource_entry, node); 179 180 180 - return resource_size(entry2->res) - resource_size(entry1->res); 181 + size1 = resource_size(entry1->res); 182 + size2 = resource_size(entry2->res); 183 + 184 + if (size1 > size2) 185 + return -1; 186 + 187 + if (size1 < size2) 188 + return 1; 189 + 190 + return 0; 181 191 } 182 192 EXPORT_SYMBOL_GPL(cdns_pcie_host_dma_ranges_cmp); 183 193