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>

authored by Matias Bjørling and committed by Jens Axboe de65d2d2 5014c311

+17 -16
+17 -16
drivers/block/null_blk.c
··· 406 .complete = null_softirq_done_fn, 407 }; 408 409 static void null_del_dev(struct nullb *nullb) 410 { 411 list_del_init(&nullb->list); ··· 431 if (queue_mode == NULL_Q_MQ) 432 blk_mq_free_tag_set(&nullb->tag_set); 433 put_disk(nullb->disk); 434 kfree(nullb); 435 } 436 ··· 474 } 475 476 return 0; 477 - } 478 - 479 - static void cleanup_queue(struct nullb_queue *nq) 480 - { 481 - kfree(nq->tag_map); 482 - kfree(nq->cmds); 483 - } 484 - 485 - static void cleanup_queues(struct nullb *nullb) 486 - { 487 - int i; 488 - 489 - for (i = 0; i < nullb->nr_queues; i++) 490 - cleanup_queue(&nullb->queues[i]); 491 - 492 - kfree(nullb->queues); 493 } 494 495 static int setup_queues(struct nullb *nullb)
··· 406 .complete = null_softirq_done_fn, 407 }; 408 409 + static void cleanup_queue(struct nullb_queue *nq) 410 + { 411 + kfree(nq->tag_map); 412 + kfree(nq->cmds); 413 + } 414 + 415 + static void cleanup_queues(struct nullb *nullb) 416 + { 417 + int i; 418 + 419 + for (i = 0; i < nullb->nr_queues; i++) 420 + cleanup_queue(&nullb->queues[i]); 421 + 422 + kfree(nullb->queues); 423 + } 424 + 425 static void null_del_dev(struct nullb *nullb) 426 { 427 list_del_init(&nullb->list); ··· 415 if (queue_mode == NULL_Q_MQ) 416 blk_mq_free_tag_set(&nullb->tag_set); 417 put_disk(nullb->disk); 418 + cleanup_queues(nullb); 419 kfree(nullb); 420 } 421 ··· 457 } 458 459 return 0; 460 } 461 462 static int setup_queues(struct nullb *nullb)