Skip to content

Commit f961f72

Browse files
jan-kiszkamatosatti
authored andcommitted
KVM: Fix PCI header check on device assignment
The masking was wrong (must have been 0x7f), and there is no need to re-read the value as pci_setup_device already does this for us. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=43339 Signed-off-by: Jan Kiszka <[email protected]> Acked-by: Alex Williamson <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
1 parent a2c2df8 commit f961f72

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

virt/kvm/assigned-dev.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
635635
int r = 0, idx;
636636
struct kvm_assigned_dev_kernel *match;
637637
struct pci_dev *dev;
638-
u8 header_type;
639638

640639
if (!(assigned_dev->flags & KVM_DEV_ASSIGN_ENABLE_IOMMU))
641640
return -EINVAL;
@@ -668,8 +667,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
668667
}
669668

670669
/* Don't allow bridges to be assigned */
671-
pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
672-
if ((header_type & PCI_HEADER_TYPE) != PCI_HEADER_TYPE_NORMAL) {
670+
if (dev->hdr_type != PCI_HEADER_TYPE_NORMAL) {
673671
r = -EPERM;
674672
goto out_put;
675673
}

0 commit comments

Comments
 (0)