driver/virtio: Check driver isn't NULL before calling remove

since the device mayn't bind to the driver yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2024-10-05 19:37:52 +08:00 committed by Alan C. Assis
parent bad1627759
commit 347c2dae29

View file

@ -364,12 +364,12 @@ int virtio_unregister_device(FAR struct virtio_device *device)
container_of(node, struct virtio_device_item_s, node);
if (item->device == device)
{
/* Call driver remove and mark item->driver NULL to indicate
* the device unmatched
*/
/* Call driver remove */
item->driver->remove(device);
item->driver = NULL;
if (item->driver)
{
item->driver->remove(device);
}
/* Remove the device from the device list and free memory */