blk-mq: fix double-free in error path
Subsystems (2)
PATCH 1/1 blk-mq: fix double-free in error path
If the allocation of bt->bs fails, then bt->map can be freed twice, once in blk_mq_init_bitmap_tags() -> bt_alloc(), and once in blk_mq_init_bitmap_tags() -> bt_free(). Fix by setting the pointer to NULL after the first free.
Cc <[email protected]>
Signed-off-by Tony Battersby <[email protected]>
---
For inclusion in kernel 3.20.
block/blk-mq-tag.c renamed from block/blk-mq-tag.c.orig +1 -0
@@ -509,6 +509,7 @@ static int bt_alloc(struct blk_mq_bitmap bt->bs =kzalloc (BT_WAIT_QUEUES *sizeof (*bt->bs),GFP_KERNEL );if (!bt->bs) {kfree (bt->map); + bt->map =NULL ;return -ENOMEM ; }
Jens Axboe
maintainerQuoted 14 lines · Tony Battersby
If the allocation of
bt->bsfails, thenbt->mapcan be freed twice, once inblk_mq_init_bitmap_tags()->bt_alloc(), and once inblk_mq_init_bitmap_tags()->bt_free(). Fix by setting the pointer to NULL after the first free.Cc <[email protected]>Signed-off-by Tony Battersby <[email protected]>---
For inclusion in kernel 3.20.
block/blk-mq-tag.c static int bt_alloc(struct blk_mq_bitmap · line 514
Quoted 6 lines
block/blk-mq-tag.c renamed from block/blk-mq-tag.c.orig +1
-0@@ -509,6 +509,7 @@ static int bt_alloc(struct blk_mq_bitmap bt->bs =kzalloc (BT_WAIT_QUEUES *sizeof (*bt->bs),GFP_KERNEL );if (!bt->bs) {kfree (bt->map); + bt->map =NULL ;return -ENOMEM ; }
Thanks Tony, applied.
Signature · 1 line
Jens Axboe