From patchwork Tue Mar 15 08:21:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 8586181 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC76F9F44D for ; Tue, 15 Mar 2016 08:21:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04BBD2025B for ; Tue, 15 Mar 2016 08:21:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE02B2021B for ; Tue, 15 Mar 2016 08:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934397AbcCOIV0 (ORCPT ); Tue, 15 Mar 2016 04:21:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:59588 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934395AbcCOIV0 (ORCPT ); Tue, 15 Mar 2016 04:21:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3323BAAB4; Tue, 15 Mar 2016 08:21:24 +0000 (UTC) From: Hannes Reinecke To: Jens Axboe Cc: Christoph Hellwig , linux-block@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH] blk-mq: sanity check for retrieving request Date: Tue, 15 Mar 2016 09:21:23 +0100 Message-Id: <1458030083-46905-1-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to check for a valid index before accessing the array element to avoid accessing invalid memory regions. Signed-off-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Jeff Moyer --- block/blk-mq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 56c0a72..4ea87d5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -544,6 +544,8 @@ EXPORT_SYMBOL(blk_mq_abort_requeue_list); struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag) { + if (unlikely(tag >= tags->nr_tags)) + return NULL; return tags->rqs[tag]; } EXPORT_SYMBOL(blk_mq_tag_to_rq);