From 91d895d9a29761aea800ff483a8da2501fbff16f Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Sat, 8 Feb 2025 16:51:50 +0800 Subject: [PATCH] fs/virtio-9p:When virtio-9p is not supported, return -ENODEV Summary: When the operating environment does not support virtio-9p and the virtio-9p server driver is not provided, -ENODEV should be returned for virtio-9p to avoid crash caused by continued execution. Signed-off-by: chenrun1 --- fs/v9fs/virtio_9p.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/v9fs/virtio_9p.c b/fs/v9fs/virtio_9p.c index 8e7cc8fb8d..5681173980 100644 --- a/fs/v9fs/virtio_9p.c +++ b/fs/v9fs/virtio_9p.c @@ -127,6 +127,13 @@ 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) + { + /* No corresponding driver was found, we should return an error */ + + ret = -ENODEV; + } + if (ret < 0) { fs_heap_free(priv);