nullblk: Fix cleanup order in null_add_dev() error path
PATCH 1/1 nullblk: Fix cleanup order in null_add_dev() error path
In null_add_dev(), if an error happen after initializing the resources for a zoned null block device, we must free these resources before exiting the function. To ensure this, move the out_cleanup_zone label after out_cleanup_disk as we jump to this latter label if an error happens after calling null_init_zoned_dev().
--- drivers/block/null_blk/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/null_blk/main.c +2 -2
@@ -1965,10 +1965,10 @@ static int null_add_dev(struct nullb_device *dev) out_ida_free:ida_free (&nullb_indexes, nullb->index); -out_cleanup_zone: -null_free_zoned_dev (dev); out_cleanup_disk:put_disk (nullb->disk); +out_cleanup_zone: +null_free_zoned_dev (dev); out_cleanup_tags:if (nullb->tag_set == &nullb->__tag_set)blk_mq_free_tag_set (nullb->tag_set);
Signature · 1 line
2.44.0
Quoted 5 lines · Damien Le Moal
In
null_add_dev(), if an error happen after initializing the resources for a zoned null block device, we must free these resources before exiting the function. To ensure this, move theout_cleanup_zonelabel afterout_cleanup_diskas we jump to this latter label if an error happens after callingnull_init_zoned_dev().
Looks good:
Quoted 8 lines · Damien Le Moal
In
null_add_dev(), if an error happen after initializing the resources for a zoned null block device, we must free these resources before exiting the function. To ensure this, move theout_cleanup_zonelabel afterout_cleanup_diskas we jump to this latter label if an error happens after callingnull_init_zoned_dev().[...]
Applied, thanks!
[1/1] nullblk: Fix cleanup order in null_add_dev() error path
commit: a057e4036487351ad25002a88c75f7d195e36d79
Best regards,
Signature · 1 line
Jens Axboe