aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/pci/pci.h
diff options
context:
space:
mode:
authorJames Sewart <jamessewart@arista.com>2019-12-10 15:51:33 -0600
committerBjorn Helgaas <bhelgaas@google.com>2019-12-18 12:21:16 -0600
commitf8bf2aeb651b3460a4b36fd7ba1ba1d31777d35c (patch)
tree202de2282e09e50ca722a0e65f336fee7c36a901 /drivers/pci/pci.h
parentPCI/IOV: Fix memory leak in pci_iov_add_virtfn() (diff)
downloadwireguard-linux-f8bf2aeb651b3460a4b36fd7ba1ba1d31777d35c.tar.xz
wireguard-linux-f8bf2aeb651b3460a4b36fd7ba1ba1d31777d35c.zip
PCI: Fix pci_add_dma_alias() bitmask size
The number of possible devfns is 256, but pci_add_dma_alias() allocated a bitmap of size 255. Fix this off-by-one error. This fixes commits 338c3149a221 ("PCI: Add support for multiple DMA aliases") and c6635792737b ("PCI: Allocate dma_alias_mask with bitmap_zalloc()"), but I doubt it was possible to see a problem because it takes 4 64-bit longs (or 8 32-bit longs) to hold 255 bits, and bitmap_zalloc() doesn't save the 255-bit size anywhere. [bhelgaas: commit log, move #define to drivers/pci/pci.h, include loop limit fix from Qian Cai: https://lore.kernel.org/r/20191218170004.5297-1-cai@lca.pw] Signed-off-by: James Sewart <jamessewart@arista.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Diffstat (limited to 'drivers/pci/pci.h')
-rw-r--r--drivers/pci/pci.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a0a53bd05a0b..6394e7746fb5 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -4,6 +4,9 @@
#include <linux/pci.h>
+/* Number of possible devfns: 0.0 to 1f.7 inclusive */
+#define MAX_NR_DEVFNS 256
+
#define PCI_FIND_CAP_TTL 48
#define PCI_VSEC_ID_INTEL_TBT 0x1234 /* Thunderbolt */