Commit d121df78 authored by Shawn.Shao's avatar Shawn.Shao Committed by Michael S. Tsirkin

vdpa_sim_blk: Fix the potential leak of mgmt_dev

If the shared_buffer allocation fails, need to unregister mgmt_dev first.

Cc: stable@vger.kernel.org
Fixes: abebb162 ("vdpa_sim_blk: support shared backend")
Signed-off-by: default avatarShawn.Shao <shawn.shao@jaguarmicro.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Message-Id: <20230821060333.1155-1-shawn.shao@jaguarmicro.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent e07744b4
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment