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: [email protected] Fixes: abebb16 ("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]>
1 parent e07744b commit d121df7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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)