PCI: Fix pci_add_dma_alias() bitmask size
authorJames Sewart <jamessewart@arista.com>
Tue, 10 Dec 2019 21:51:33 +0000 (15:51 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:36:24 +0000 (08:36 +0100)
commitb3224bf307098212df0e8c122bebe2888e3045bb
tree8c74365d6a78c0ac241da8ecef12eee4876d4e24
parent071963d3714301c7b14c8e71200d9bf5c30925ce
PCI: Fix pci_add_dma_alias() bitmask size

[ Upstream commit f8bf2aeb651b3460a4b36fd7ba1ba1d31777d35c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/search.c