This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f41d2797165 fs/v9fs: unregister driver when no device found
f41d2797165 is described below

commit f41d279716536f1e12ab7743070f807ad9eb2c84
Author: liaoao <[email protected]>
AuthorDate: Wed Nov 11 16:17:56 2026 +0800

    fs/v9fs: unregister driver when no device found
    
    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 registration 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.
    
    Signed-off-by: liaoao <[email protected]>
    Signed-off-by: jingfei <[email protected]>
---
 fs/v9fs/virtio_9p.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/v9fs/virtio_9p.c b/fs/v9fs/virtio_9p.c
index 9a02b500e58..a4e18996abb 100644
--- a/fs/v9fs/virtio_9p.c
+++ b/fs/v9fs/virtio_9p.c
@@ -192,10 +192,11 @@ static int virtio_9p_create(FAR struct v9fs_transport_s 
**transport,
   priv->transport.ops = &g_virtio_9p_transport_ops;
   *transport = &priv->transport;
   ret = virtio_register_driver(&priv->vdrv);
-  if (priv->vdev == NULL)
+  if (ret >= 0 && priv->vdev == NULL)
     {
       /* No corresponding driver was found, we should return an error */
 
+      virtio_unregister_driver(&priv->vdrv);
       ret = -ENODEV;
     }
 

Reply via email to