
13 Apr
2022
13 Apr
'22
3:14 p.m.
On Wed, Mar 30, 2022 at 12:59 AM Andrew Scull ascull@google.com wrote:
Read the virtio PCI capability out of the device configuration space to a struct rather than accessing fields directly from the configuration space as they are needed. This both makes access to the fields easier and avoids re-reading fields.
Re-reading fields could result in time-of-check to time-of-use problems, should the value in the configuration space change. The range check of the `bar` field and the later call to `dm_pci_read_bar32()` is an example of where this could happen.
Signed-off-by: Andrew Scull ascull@google.com
drivers/virtio/virtio_pci_modern.c | 72 ++++++++++++++++-------------- 1 file changed, 38 insertions(+), 34 deletions(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com