From 62b048833cb7a3dcf5968494a81303aa7d617174 Mon Sep 17 00:00:00 2001 From: Jian Jun Chen Date: Fri, 31 Aug 2018 10:59:03 +0800 Subject: [PATCH 420/550] VBS-K: Check whether vhm_client_id is valid before deregister Need to check whether vhm_client_id is valid before trying to deregister from VHM. It is possbile that virtio_dev_deregister is called more than once by vbs-k driver. Signed-off-by: Jian Jun Chen Reviewed-by: Zhao Yakui --- drivers/vbs/vbs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vbs/vbs.c b/drivers/vbs/vbs.c index 7427942c12f7..c2d8a5262a8d 100644 --- a/drivers/vbs/vbs.c +++ b/drivers/vbs/vbs.c @@ -135,12 +135,15 @@ long virtio_dev_register(struct virtio_dev_info *dev) long virtio_dev_deregister(struct virtio_dev_info *dev) { + if (dev->_ctx.vhm_client_id < 0) + return 0; + acrn_ioreq_del_iorange(dev->_ctx.vhm_client_id, dev->io_range_type ? REQ_MMIO : REQ_PORTIO, dev->io_range_start, dev->io_range_start + dev->io_range_len); - acrn_ioreq_destroy_client(dev->_ctx.vhm_client_id); + dev->_ctx.vhm_client_id = -1; return 0; } @@ -300,6 +303,8 @@ long virtio_dev_init(struct virtio_dev_info *dev, for (i = 0; i < nvq; i++) virtio_vq_reset(&vqs[i]); + dev->_ctx.vhm_client_id = -1; + return 0; } EXPORT_SYMBOL_GPL(virtio_dev_init); -- 2.19.1