linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rex Zhu <Rex.Zhu@amd.com>
To: <bhelgaas@google.com>, <michel.daenzer@amd.com>,
	<alexander.deucher@amd.com>, <linux-pci@vger.kernel.org>
Cc: Rex Zhu <Rex.Zhu@amd.com>
Subject: [PATCH 2/2] PCI: Add check code for last image indicator not set
Date: Tue, 5 Jun 2018 09:46:46 +0800	[thread overview]
Message-ID: <1528163206-4136-2-git-send-email-Rex.Zhu@amd.com> (raw)
In-Reply-To: <1528163206-4136-1-git-send-email-Rex.Zhu@amd.com>

if last image indicator was not set in the PCI data struct,
print out "No more image in the PCI ROM" instand of
loop back and print "Invalid PCI ROM header signature" info.

Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/pci/rom.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index a5c6016..a8b916b 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -110,6 +110,12 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size)
 		/* Avoid iterating through memory outside the resource window */
 		if (image >= rom + size)
 			break;
+		if (!last_image) {
+			if (readw(image) != 0xAA55) {
+				pci_info(pdev, "No more image in the PCI ROM\n");
+				break;
+			}
+		}
 	} while (length && !last_image);
 
 	/* never return a size larger than the PCI resource window */
-- 
1.9.1

  reply	other threads:[~2018-06-05  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05  1:46 [PATCH 1/2] PCI: Avoid access memory outside the resource window Rex Zhu
2018-06-05  1:46 ` Rex Zhu [this message]
2018-06-12 14:34 ` Deucher, Alexander
2018-06-30  2:20 ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1528163206-4136-2-git-send-email-Rex.Zhu@amd.com \
    --to=rex.zhu@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=michel.daenzer@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).