From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 7 Jun 2016 10:57:36 -0400 From: Keith Busch To: Christoph Hellwig Cc: axboe@kernel.dk, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Ming Lin Subject: Re: [PATCH 1/8] blk-mq: add blk_mq_alloc_request_hctx Message-ID: <20160607145736.GB28414@localhost.localdomain> References: <1465248119-17875-1-git-send-email-hch@lst.de> <1465248119-17875-2-git-send-email-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <1465248119-17875-2-git-send-email-hch@lst.de> List-ID: On Mon, Jun 06, 2016 at 11:21:52PM +0200, Christoph Hellwig wrote: > +struct request *blk_mq_alloc_request_hctx(struct request_queue *q, int rw, > + unsigned int flags, unsigned int hctx_idx) > +{ > + struct blk_mq_hw_ctx *hctx; > + struct blk_mq_ctx *ctx; > + struct request *rq; > + struct blk_mq_alloc_data alloc_data; > + int ret; > + > + ret = blk_queue_enter(q, flags & BLK_MQ_REQ_NOWAIT); > + if (ret) > + return ERR_PTR(ret); > + > + hctx = q->queue_hw_ctx[hctx_idx]; We probably want to check 'if (hctx_idx < q->nr_hw_queues)' before getting the hctx. Even if hctx_idx was origially valid, it's possible (though unlikely) blk_queue_enter waits on reallocating h/w contexts, which can make hctx_idx invalid.