From 2749fb1b2a93744ddf043e3bd8c6b78bbca20b44 Mon Sep 17 00:00:00 2001 From: lyx634449800 Date: Wed, 13 Mar 2024 10:28:11 +0000 Subject: [PATCH] vhost_vdpa: Fix the error of not executing atomic_dec driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I98AT9 CVE: NA ----------------------------- In the vhost_vdpa_open function, if atomic_cmpxchg succeeds but vhost_vdpa_alloc_domain fails, directly returning to the user space without performing the atomic_dec operation will lead to an exception Signed-off-by: lyx634449800 --- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index eed51d004531..c9b105977b11 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1493,7 +1493,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) return -EBUSY; r = vhost_vdpa_alloc_domain(v); if (r) - return r; + goto close; nvqs = v->nvqs; r = vhost_vdpa_reset(v, VDPA_DEV_RESET_OPEN); @@ -1522,6 +1522,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) err: vhost_vdpa_free_domain(v); +close: atomic_dec(&v->opened); return r; } -- Gitee