diff options
author | Shawn.Shao <[email protected]> | 2023-08-21 14:03:33 +0800 |
---|---|---|
committer | Michael S. Tsirkin <[email protected]> | 2023-10-18 11:28:47 -0400 |
commit | d121df789b159e9a8ee770666f210975a81e8111 (patch) | |
tree | 99af848b139ca46ba3b5124d33ec15dcfe03ea7e | |
parent | e07744b43d3ad10b040f0ec464b6323ca96903d6 (diff) |
vdpa_sim_blk: Fix the potential leak of mgmt_dev
If the shared_buffer allocation fails, need to unregister mgmt_dev first.
Cc: [email protected]
Fixes: abebb16254b36 ("vdpa_sim_blk: support shared backend")
Signed-off-by: Shawn.Shao <[email protected]>
Acked-by: Jason Wang <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
-rw-r--r-- | drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c index 00d7d72713be..b3a3cb165795 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c @@ -499,12 +499,13 @@ static int __init vdpasim_blk_init(void) GFP_KERNEL); if (!shared_buffer) { ret = -ENOMEM; - goto parent_err; + goto mgmt_dev_err; } } return 0; - +mgmt_dev_err: + vdpa_mgmtdev_unregister(&mgmt_dev); parent_err: device_unregister(&vdpasim_blk_mgmtdev); return ret; |