Skip to contentSkip to conversation

null_blk: boundary check queue_mode and irqmode

PATCH Superseded Matias Bjørling 2 participants 2 messages Nov 26, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 null_blk: boundary check queue_mode and irqmode

When either queue_mode or irq_mode parameter is set outside its boundaries, the driver will not complete requests. This stalls driver initialization when partitions are probed. Fix by setting out of bound values to the parameters default.

---
 drivers/block/null_blk.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/block/null_blk.c +13 -1
index caa6121..efe9f76 100644
@@ -506,7 +506,7 @@ static int null_add_dev(void)
 		rv = init_driver_queues(nullb);
 		if (rv)
 			goto out_cleanup_blk_queue;
-	} else {
+	} else if (queue_mode == NULL_Q_RQ) {
 		nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node);
 		if (!nullb->q) {
 			rv = -ENOMEM;
@@ -574,6 +574,18 @@ static int __init null_init(void)
 		bs = PAGE_SIZE;
 	}
 
+	if (queue_mode < 0 || queue_mode > NULL_Q_MQ) {
+		pr_warn("null_blk: invalid queue mode\n");
+		pr_warn("null_blk: defaults queue mode to multiqueue\n");
+		queue_mode = NULL_Q_MQ;
+	}
+
+	if (irqmode < 0 || irqmode > NULL_IRQ_TIMER) {
+		pr_warn("null_blk: invalid irq mode\n");
+		pr_warn("null_blk: defauls irq mode to softirq\n");
+		irqmode = NULL_IRQ_SOFTIRQ;
+	}
+
 	if (queue_mode == NULL_Q_MQ && use_per_node_hctx) {
 		if (submit_queues < nr_online_nodes) {
 			pr_warn("null_blk: submit_queues param is set to %u.",
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 28 lines · Matias Bjørling

When either queue_mode or irq_mode parameter is set outside its boundaries, the driver will not complete requests. This stalls driver initialization when partitions are probed. Fix by setting out of bound values to the parameters default.

---
  drivers/block/null_blk.c | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
drivers/block/null_blk.c +2 -1
index caa6121..efe9f76 100644
@@ -506,7 +506,7 @@ static int null_add_dev(void)
  		rv = init_driver_queues(nullb);
  		if (rv)
  			goto out_cleanup_blk_queue;
-	} else {
+	} else if (queue_mode == NULL_Q_RQ) {
  		nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node);
  		if (!nullb->q) {
  			rv = -ENOMEM;
@@ -574,6 +574,18 @@ static int __init null_init(void)
  		bs = PAGE_SIZE;
  	}
 
+	if (queue_mode < 0 || queue_mode > NULL_Q_MQ) {

drivers/block/null_blk.c static int __init null_init(void) · line 587

Quoted 10 lines
drivers/block/null_blk.c +10 -0
+		pr_warn("null_blk: invalid queue mode\n");
+		pr_warn("null_blk: defaults queue mode to multiqueue\n");
+		queue_mode = NULL_Q_MQ;
+	}
+
+	if (irqmode < 0 || irqmode > NULL_IRQ_TIMER) {
+		pr_warn("null_blk: invalid irq mode\n");
+		pr_warn("null_blk: defauls irq mode to softirq\n");
+		irqmode = NULL_IRQ_SOFTIRQ;
+	}

Lets fix these by using module_param_cb() instead to reject invalid values upfront.

Signature · 6 lines
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html