linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: fix invalid ROM content detection in pci_get_rom_size()
@ 2015-11-06 12:16 Vladis Dronov
  2015-11-24 17:03 ` Bjorn Helgaas
  0 siblings, 1 reply; 5+ messages in thread
From: Vladis Dronov @ 2015-11-06 12:16 UTC (permalink / raw)
  To: linux-pci; +Cc: Vladis Dronov

Make pci_get_rom_size() to check all bytes in the PCI ROM signature
and issue a warning if the values are not following the standard.

Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---
 drivers/pci/rom.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index eb0ad53..34f8b2c 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -77,22 +77,17 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 	do {
 		void __iomem *pds;
 		/* Standard PCI ROMs start out with these bytes 55 AA */
-		if (readb(image) != 0x55) {
-			dev_err(&pdev->dev, "Invalid ROM contents\n");
+		if ((readb(image) != 0x55) || (readb(image + 1) != 0xAA)) {
+			dev_err(&pdev->dev, "Invalid PCI ROM signature\n");
 			break;
 		}
-		if (readb(image + 1) != 0xAA)
-			break;
 		/* get the PCI data structure and check its signature */
 		pds = image + readw(image + 24);
-		if (readb(pds) != 'P')
-			break;
-		if (readb(pds + 1) != 'C')
-			break;
-		if (readb(pds + 2) != 'I')
-			break;
-		if (readb(pds + 3) != 'R')
+		if ((readb(pds) != 'P') || (readb(pds + 1) != 'C') ||
+			(readb(pds + 2) != 'I') || (readb(pds + 3) != 'R')) {
+			dev_err(&pdev->dev, "Invalid PCI ROM data signature\n");
 			break;
+		}
 		last_image = readb(pds + 21) & 0x80;
 		length = readw(pds + 16);
 		image += length * 512;
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-04 23:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-06 12:16 [PATCH] PCI: fix invalid ROM content detection in pci_get_rom_size() Vladis Dronov
2015-11-24 17:03 ` Bjorn Helgaas
2015-11-27 17:05   ` Vladis Dronov
2015-11-27 17:20   ` [PATCH v2] PCI: fix missing ROM content warning " Vladis Dronov
2015-12-04 23:44     ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).