From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: [PATCH] null_blk: boundary check queue_mode and irqmode Date: Wed, 26 Nov 2014 08:21:39 -0700 Message-ID: <5475F003.6070209@kernel.dk> References: <1417014178-13007-1-git-send-email-m@bjorling.me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE To: =?UTF-8?B?TWF0aWFzIEJqw7hybGluZw==?= , axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: Received: from mail-pd0-f181.google.com ([209.85.192.181]:62954 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753079AbaKZPVj (ORCPT ); Wed, 26 Nov 2014 10:21:39 -0500 Received: by mail-pd0-f181.google.com with SMTP id z10so2997604pdj.12 for ; Wed, 26 Nov 2014 07:21:38 -0800 (PST) In-Reply-To: <1417014178-13007-1-git-send-email-m@bjorling.me> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 11/26/2014 08:02 AM, Matias Bj=C3=B8rling wrote: > When either queue_mode or irq_mode parameter is set outside its bound= aries, the > driver will not complete requests. This stalls driver initialization = when > partitions are probed. Fix by setting out of bound values to the para= meters > default. > > Signed-off-by: Matias Bj=C3=B8rling > --- > drivers/block/null_blk.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c > index caa6121..efe9f76 100644 > --- a/drivers/block/null_blk.c > +++ b/drivers/block/null_blk.c > @@ -506,7 +506,7 @@ static int null_add_dev(void) > rv =3D init_driver_queues(nullb); > if (rv) > goto out_cleanup_blk_queue; > - } else { > + } else if (queue_mode =3D=3D NULL_Q_RQ) { > nullb->q =3D blk_init_queue_node(null_request_fn, &nullb->lock, h= ome_node); > if (!nullb->q) { > rv =3D -ENOMEM; > @@ -574,6 +574,18 @@ static int __init null_init(void) > bs =3D 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 =3D 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 =3D NULL_IRQ_SOFTIRQ; > + } Lets fix these by using module_param_cb() instead to reject invalid=20 values upfront. --=20 Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html