diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2025-09-24 11:51:53 -0400 | 
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2025-10-05 09:01:08 -0400 | 
| commit | bab681f752048c3bc22d561b1d314c7ec16419c9 (patch) | |
| tree | 021203b3d91f36ad43c52ccc3c2ee24abb571599 /scripts/lib/kdoc/kdoc_parser.py | |
| parent | acaa3be3f7f73d9aafeb2454c01fe50eb8b4a807 (diff) | |
| download | qemu-bab681f752048c3bc22d561b1d314c7ec16419c9.zip qemu-bab681f752048c3bc22d561b1d314c7ec16419c9.tar.gz qemu-bab681f752048c3bc22d561b1d314c7ec16419c9.tar.bz2  | |
pcie_sriov: make pcie_sriov_pf_exit() safe on non-SR-IOV devices
Commit 3f9cfaa92c96 ("virtio-pci: Implement SR-IOV PF") added an
unconditional call from virtio_pci_exit() to pcie_sriov_pf_exit().
pcie_sriov_pf_exit() reads from the SR-IOV Capability in Configuration
Space:
  uint8_t *cfg = dev->config + dev->exp.sriov_cap;
  ...
  unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF));
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This results in undefined behavior when dev->exp.sriov_cap is 0 because
this is not an SR-IOV device. For example, unparent_vfs() segfaults when
total_vfs happens to be non-zero.
Fix this by returning early from pcie_sriov_pf_exit() when
dev->exp.sriov_cap is 0 because this is not an SR-IOV device.
Cc: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: Michael S. Tsirkin <mst@redhat.com>
Reported-by: Qing Wang <qinwang@redhat.com>
Buglink: https://issues.redhat.com/browse/RHEL-116443
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Fixes: cab1398a60eb ("pcie_sriov: Reuse SR-IOV VF device instances")
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20250924155153.579495-1-stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'scripts/lib/kdoc/kdoc_parser.py')
0 files changed, 0 insertions, 0 deletions
