Skip to content

Commit d121df7

Browse files
Shawn.Shaomstsirkin
authored andcommitted
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: abebb16 ("vdpa_sim_blk: support shared backend") Signed-off-by: Shawn.Shao <shawn.shao@jaguarmicro.com> Acked-by: Jason Wang <jasowang@redhat.com> Message-Id: <20230821060333.1155-1-shawn.shao@jaguarmicro.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent e07744b commit d121df7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/vdpa/vdpa_sim/vdpa_sim_blk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,13 @@ static int __init vdpasim_blk_init(void)
499499
GFP_KERNEL);
500500
if (!shared_buffer) {
501501
ret = -ENOMEM;
502-
goto parent_err;
502+
goto mgmt_dev_err;
503503
}
504504
}
505505

506506
return 0;
507-
507+
mgmt_dev_err:
508+
vdpa_mgmtdev_unregister(&mgmt_dev);
508509
parent_err:
509510
device_unregister(&vdpasim_blk_mgmtdev);
510511
return ret;

0 commit comments

Comments
 (0)