diff options
author | Matias Bjørling <mb@lightnvm.io> | 2015-08-31 14:17:18 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-09-02 16:49:41 -0600 |
commit | de65d2d26f81f7f84c7258b3a137f20e8fa5bb6a (patch) | |
tree | 7a19b0d7c08f2e5cb056a95d591800b96d801681 /drivers/block | |
parent | 5014c311baa2b21384321fa4a9f617a92e3e56f0 (diff) | |
download | linux-de65d2d26f81f7f84c7258b3a137f20e8fa5bb6a.tar.gz linux-de65d2d26f81f7f84c7258b3a137f20e8fa5bb6a.tar.bz2 linux-de65d2d26f81f7f84c7258b3a137f20e8fa5bb6a.zip |
null_blk: fix memory leak on cleanup
Driver was not freeing the memory allocated for internal nullb queues.
This patch frees the memory during driver unload.
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/null_blk.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 17269a3b85f2..d394a85aa92e 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -406,6 +406,22 @@ static struct blk_mq_ops null_mq_ops = { .complete = null_softirq_done_fn, }; +static void cleanup_queue(struct nullb_queue *nq) +{ + kfree(nq->tag_map); + kfree(nq->cmds); +} + +static void cleanup_queues(struct nullb *nullb) +{ + int i; + + for (i = 0; i < nullb->nr_queues; i++) + cleanup_queue(&nullb->queues[i]); + + kfree(nullb->queues); +} + static void null_del_dev(struct nullb *nullb) { list_del_init(&nullb->list); @@ -415,6 +431,7 @@ static void null_del_dev(struct nullb *nullb) if (queue_mode == NULL_Q_MQ) blk_mq_free_tag_set(&nullb->tag_set); put_disk(nullb->disk); + cleanup_queues(nullb); kfree(nullb); } @@ -459,22 +476,6 @@ static int setup_commands(struct nullb_queue *nq) return 0; } -static void cleanup_queue(struct nullb_queue *nq) -{ - kfree(nq->tag_map); - kfree(nq->cmds); -} - -static void cleanup_queues(struct nullb *nullb) -{ - int i; - - for (i = 0; i < nullb->nr_queues; i++) - cleanup_queue(&nullb->queues[i]); - - kfree(nullb->queues); -} - static int setup_queues(struct nullb *nullb) { nullb->queues = kzalloc(submit_queues * sizeof(struct nullb_queue), |