You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/10/05 15:05:23 UTC
(nuttx) 04/08: driver/vhost: Check driver isn't NULL before calling remove
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit bad1627759decc5fafb13a5886becf3bd6a6c6a1
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Oct 5 19:30:43 2024 +0800
driver/vhost: Check driver isn't NULL before calling remove
since the device mayn't bind to the driver yet
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/vhost/vhost.c | 34 +++++++++++++---------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 05470ce6e7..1d8a0d015b 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -150,25 +150,6 @@ static void vhost_defered_probe_work(FAR void *arg)
nxmutex_unlock(&g_vhost_bus.lock);
}
-/****************************************************************************
- * Name: vhost_remove_device
- ****************************************************************************/
-
-static void vhost_remove_device(FAR struct vhost_device_item_s *item)
-{
- /* Call driver remove and mark item->driver NULL to indicate
- * the device unmatched.
- */
-
- item->driver->remove(item->device);
- item->driver = NULL;
-
- /* Remove the device from the device list and free memory */
-
- list_delete(&item->node);
- kmm_free(item);
-}
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -352,7 +333,17 @@ int vhost_unregister_device(FAR struct vhost_device *device)
{
if (item->device == device)
{
- vhost_remove_device(item);
+ /* Call driver remove */
+
+ if (item->driver)
+ {
+ item->driver->remove(item->device);
+ }
+
+ /* Remove the device from the device list and free memory */
+
+ list_delete(&item->node);
+ kmm_free(item);
goto out;
}
}
@@ -362,7 +353,8 @@ int vhost_unregister_device(FAR struct vhost_device *device)
{
if (item->device == device)
{
- vhost_remove_device(item);
+ list_delete(&item->node);
+ kmm_free(item);
goto out;
}
}