Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Virtio-9P device attach: fix initialization of virtio_9p struct
Since commit d037970, in multi-vCPU instances root filesystem initialization can complete before PCI bus discovery; this means that any filesystem mount points specified in the manifest options can be already processed by the time a virtio-9p device is probed and a corresponding volume is added; this in turn means that the `volume_add()` function called by `v9p_dev_attach()` can trigger a direct call to `v9p_fs_init()`. The `v9p_fs_init()` function uses the `general` field of the `virtio_9p` struct, which in the current code is initialized after calling the `volume_add()` function; this causes `v9p_fs_init()` to access an uninitialized pointer, leading to an unhandled page fault. The same issue applies to the `backed` field of the struct. This change fixes the above issue by moving the initialization of the struct fields before the call to `volume_add()`. In addition, the unused `dev` field is being removed, and setting the DRIVER_OK flag in the device status field is being moved before the call to `volume_add()` (according to the virtio specs, a driver must not send any buffer available notifications to the device before setting DRIVER_OK).
- Loading branch information