diff options
author | Jan Kara <jack@suse.cz> | 2014-10-22 09:34:21 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-10-22 09:59:25 -0400 |
commit | 31f9690e6eaf549f3e643f6a8f7dab84fd31997a (patch) | |
tree | c31966132649fc7154b57536f6f8355251d201f1 /drivers/block/null_blk.c | |
parent | 76d8137a31139f0d69ecc4177497ad6b8d4f016c (diff) |
null_blk: Cleanup error recovery in null_add_dev()
When creation of queues fails in init_driver_queues(), we free the
queues. But null_add_dev() doesn't test for this failure and continues
with the setup leading to strange consequences, likely oops. Fix the
problem by testing whether init_driver_queues() failed and do proper
error cleanup.
Coverity-id: 1148005
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/null_blk.c')
-rw-r--r-- | drivers/block/null_blk.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 2671a3f02f0c..8001e812018b 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c | |||
@@ -450,14 +450,10 @@ static int init_driver_queues(struct nullb *nullb) | |||
450 | 450 | ||
451 | ret = setup_commands(nq); | 451 | ret = setup_commands(nq); |
452 | if (ret) | 452 | if (ret) |
453 | goto err_queue; | 453 | return ret; |
454 | nullb->nr_queues++; | 454 | nullb->nr_queues++; |
455 | } | 455 | } |
456 | |||
457 | return 0; | 456 | return 0; |
458 | err_queue: | ||
459 | cleanup_queues(nullb); | ||
460 | return ret; | ||
461 | } | 457 | } |
462 | 458 | ||
463 | static int null_add_dev(void) | 459 | static int null_add_dev(void) |
@@ -507,7 +503,9 @@ static int null_add_dev(void) | |||
507 | goto out_cleanup_queues; | 503 | goto out_cleanup_queues; |
508 | } | 504 | } |
509 | blk_queue_make_request(nullb->q, null_queue_bio); | 505 | blk_queue_make_request(nullb->q, null_queue_bio); |
510 | init_driver_queues(nullb); | 506 | rv = init_driver_queues(nullb); |
507 | if (rv) | ||
508 | goto out_cleanup_blk_queue; | ||
511 | } else { | 509 | } else { |
512 | nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); | 510 | nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); |
513 | if (!nullb->q) { | 511 | if (!nullb->q) { |
@@ -516,7 +514,9 @@ static int null_add_dev(void) | |||
516 | } | 514 | } |
517 | blk_queue_prep_rq(nullb->q, null_rq_prep_fn); | 515 | blk_queue_prep_rq(nullb->q, null_rq_prep_fn); |
518 | blk_queue_softirq_done(nullb->q, null_softirq_done_fn); | 516 | blk_queue_softirq_done(nullb->q, null_softirq_done_fn); |
519 | init_driver_queues(nullb); | 517 | rv = init_driver_queues(nullb); |
518 | if (rv) | ||
519 | goto out_cleanup_blk_queue; | ||
520 | } | 520 | } |
521 | 521 | ||
522 | nullb->q->queuedata = nullb; | 522 | nullb->q->queuedata = nullb; |