* [PATCH] null_blk: Cleanup error recovery in null_add_dev()
@ 2014-10-22 13:34 Jan Kara
2014-10-22 13:59 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2014-10-22 13:34 UTC (permalink / raw)
To: Jens Axboe; +Cc: hch, LKML, Jan Kara
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>
---
drivers/block/null_blk.c | 14 +++++++-------
1 file 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)
ret = setup_commands(nq);
if (ret)
- goto err_queue;
+ return ret;
nullb->nr_queues++;
}
-
return 0;
-err_queue:
- cleanup_queues(nullb);
- return ret;
}
static int null_add_dev(void)
@@ -507,7 +503,9 @@ static int null_add_dev(void)
goto out_cleanup_queues;
}
blk_queue_make_request(nullb->q, null_queue_bio);
- init_driver_queues(nullb);
+ rv = init_driver_queues(nullb);
+ if (rv)
+ goto out_cleanup_blk_queue;
} else {
nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node);
if (!nullb->q) {
@@ -516,7 +514,9 @@ static int null_add_dev(void)
}
blk_queue_prep_rq(nullb->q, null_rq_prep_fn);
blk_queue_softirq_done(nullb->q, null_softirq_done_fn);
- init_driver_queues(nullb);
+ rv = init_driver_queues(nullb);
+ if (rv)
+ goto out_cleanup_blk_queue;
}
nullb->q->queuedata = nullb;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] null_blk: Cleanup error recovery in null_add_dev()
2014-10-22 13:34 [PATCH] null_blk: Cleanup error recovery in null_add_dev() Jan Kara
@ 2014-10-22 13:59 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2014-10-22 13:59 UTC (permalink / raw)
To: Jan Kara; +Cc: hch, LKML
On 10/22/2014 07:34 AM, Jan Kara wrote:
> 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.
Thanks Jan, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-22 13:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 13:34 [PATCH] null_blk: Cleanup error recovery in null_add_dev() Jan Kara
2014-10-22 13:59 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox