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
This commit is contained in:
Bjorn Helgaas 2026-02-06 17:09:33 -06:00
commit 9a82173951

View file

@ -173,11 +173,21 @@ int cdns_pcie_host_dma_ranges_cmp(void *priv, const struct list_head *a,
const struct list_head *b)
{
struct resource_entry *entry1, *entry2;
u64 size1, size2;
entry1 = container_of(a, struct resource_entry, node);
entry2 = container_of(b, struct resource_entry, node);
return resource_size(entry2->res) - resource_size(entry1->res);
size1 = resource_size(entry1->res);
size2 = resource_size(entry2->res);
if (size1 > size2)
return -1;
if (size1 < size2)
return 1;
return 0;
}
EXPORT_SYMBOL_GPL(cdns_pcie_host_dma_ranges_cmp);