Commit 5a4af2ca authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/resource'

- Restructure pci_dev_for_each_resource() to avoid computing the address of
  an out-of-bounds array element (the bounds check was performed later so
  the element was never actually *read*, but it's nicer to avoid even
  computing an out-of-bounds address) (Andy Shevchenko)

* pci/resource:
  PCI: Avoid potential out-of-bounds read in pci_dev_for_each_resource()
parents 18c3850f 3171e46d
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2129,12 +2129,12 @@ int pci_iobar_pfn(struct pci_dev *pdev, int bar, struct vm_area_struct *vma);

#define __pci_dev_for_each_res0(dev, res, ...)				  \
	for (unsigned int __b = 0;					  \
	     res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES;	\
	     __b < PCI_NUM_RESOURCES && (res = pci_resource_n(dev, __b)); \
	     __b++)

#define __pci_dev_for_each_res1(dev, res, __b)				  \
	for (__b = 0;							  \
	     res = pci_resource_n(dev, __b), __b < PCI_NUM_RESOURCES;	\
	     __b < PCI_NUM_RESOURCES && (res = pci_resource_n(dev, __b)); \
	     __b++)

#define pci_dev_for_each_resource(dev, res, ...)			\