jingfei195887 opened a new pull request, #21691:
URL: https://github.com/apache/nuttx/pull/21691

   ## Summary
   
   `virtio_9p_create()` adds its driver to the virtio bus and, when no
   matching device is found, frees it without removing it from the bus
   driver list. The next `virtio_register_driver()` or device probe then
   walks a list that contains freed memory.
   
   Unregister the driver before freeing it. Only do so when the
   registration itself succeeded.
   
   ## Impact
   
   A v9fs mount over virtio that finds no device still fails with ENODEV,
   but no longer leaves a freed node in the virtio driver list.
   
   ## Testing
   
   Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 
03aea78639 (rebased onto 6f47a1c3d6; the one new commit does not touch fs/), 
`sim:nsh` with
   `CONFIG_DRIVERS_VIRTIO_MMIO=y`, `CONFIG_FS_V9FS=y`,
   `CONFIG_V9FS_VIRTIO_9P=y`. A small test program registers a dummy
   virtio driver for an unused device id, then calls
   `mount(NULL, "/v9", "v9fs", 0, "trans=virtio,tag=...")` five times with
   no 9p device present, and finally checks the list node after the dummy
   driver:
   
   | | master | this PR |
   |---|---|---|
   | each `mount()` | -1, ENODEV | -1, ENODEV |
   | node after the dummy driver | a freed 9p driver | the list head |
   
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   - Make and CMake builds pass; `ostest` exits with status 0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to