aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/lguest/boot.c
diff options
context:
space:
mode:
authorPaul Bolle <pebolle@tiscali.nl>2016-03-03 07:01:40 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-06-10 05:39:09 -0400
commit7faf90ef995ea470f32f43810266ece8ac8ba6c7 (patch)
tree06f5b451c84c9ad10bd6770ddd7e56ac2e736f2c /arch/x86/lguest/boot.c
parent0145071b33142cbccffb51486b1ce921677b1d2d (diff)
lguest: Read length of device_cap later
Read the length of the capability with type VIRTIO_PCI_CAP_DEVICE_CFG only when we're sure we're going to need it. Which is just before the check whether the virtio console actually has an emerg_wr field. Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: lguest@lists.ozlabs.org Link: http://lkml.kernel.org/r/1457006501-5377-2-git-send-email-pebolle@tiscali.nl Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/lguest/boot.c')
-rw-r--r--arch/x86/lguest/boot.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 3847e736702e..146d11c8cf78 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -1258,7 +1258,7 @@ static void probe_pci_console(void)
1258 u8 vndr = read_pci_config_byte(0, 1, 0, cap); 1258 u8 vndr = read_pci_config_byte(0, 1, 0, cap);
1259 if (vndr == PCI_CAP_ID_VNDR) { 1259 if (vndr == PCI_CAP_ID_VNDR) {
1260 u8 type, bar; 1260 u8 type, bar;
1261 u32 offset, length; 1261 u32 offset;
1262 1262
1263 type = read_pci_config_byte(0, 1, 0, 1263 type = read_pci_config_byte(0, 1, 0,
1264 cap + offsetof(struct virtio_pci_cap, cfg_type)); 1264 cap + offsetof(struct virtio_pci_cap, cfg_type));
@@ -1266,15 +1266,12 @@ static void probe_pci_console(void)
1266 cap + offsetof(struct virtio_pci_cap, bar)); 1266 cap + offsetof(struct virtio_pci_cap, bar));
1267 offset = read_pci_config(0, 1, 0, 1267 offset = read_pci_config(0, 1, 0,
1268 cap + offsetof(struct virtio_pci_cap, offset)); 1268 cap + offsetof(struct virtio_pci_cap, offset));
1269 length = read_pci_config(0, 1, 0,
1270 cap + offsetof(struct virtio_pci_cap, length));
1271 1269
1272 switch (type) { 1270 switch (type) {
1273 case VIRTIO_PCI_CAP_DEVICE_CFG: 1271 case VIRTIO_PCI_CAP_DEVICE_CFG:
1274 if (bar == 0) { 1272 if (bar == 0) {
1275 device_cap = cap; 1273 device_cap = cap;
1276 device_offset = offset; 1274 device_offset = offset;
1277 device_len = length;
1278 } 1275 }
1279 break; 1276 break;
1280 case VIRTIO_PCI_CAP_PCI_CFG: 1277 case VIRTIO_PCI_CAP_PCI_CFG:
@@ -1297,6 +1294,8 @@ static void probe_pci_console(void)
1297 * emerg_wr. If it doesn't support VIRTIO_CONSOLE_F_EMERG_WRITE 1294 * emerg_wr. If it doesn't support VIRTIO_CONSOLE_F_EMERG_WRITE
1298 * it should ignore the access. 1295 * it should ignore the access.
1299 */ 1296 */
1297 device_len = read_pci_config(0, 1, 0,
1298 device_cap + offsetof(struct virtio_pci_cap, length));
1300 if (device_len < (offsetof(struct virtio_console_config, emerg_wr) 1299 if (device_len < (offsetof(struct virtio_console_config, emerg_wr)
1301 + sizeof(u32))) { 1300 + sizeof(u32))) {
1302 printk(KERN_ERR "lguest: console missing emerg_wr field\n"); 1301 printk(KERN_ERR "lguest: console missing emerg_wr field\n");