Received: by 10.223.164.202 with SMTP id h10csp604289wrb; Mon, 13 Nov 2017 11:37:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ83+vlxjEty5NarvDZzBpfDbkxqV5e316f3LKrTEiG6j7kO/nSXsFq2eTFTvGh2MyA3Rdi X-Received: by 10.99.113.86 with SMTP id b22mr6578793pgn.309.1510601871907; Mon, 13 Nov 2017 11:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510601871; cv=none; d=google.com; s=arc-20160816; b=sO4XSnnRVImTadgmb7bcqfGVcAW7qdvpA92U/J37B9utKIkefDVG9a4nWmDeZjA89v jaB7hFYSwL7iuXihNj1JXLNP5KaHeobPRymqKhfZHvqJgEUd4+rCziWB5KT39BdZj7c1 /htRlAcaO+xy0nrq+zASppGYEL/Ee2JIEXOnfT4do+Nn0Dh3QN827cn6lgYJffxhAmOy pRYFTWGrcHOnsxwp01uWkvAr2ZO25v16XXnc9+d94+6TWtol6PikRH2ouAiWjj3Vmnqj J7gMIii0qZpXjnsQpWbxmFj+izfeMV/rbEIWWTYU/6tKsqqSu3s1PY6hXGJSeOAmHmPR xy9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=QtvSSAo3ntucXrV4vbdLz/nkfZAlQgPRqRKo5WYWNuo=; b=zbC8+/EuGqBDHF+GC9jFXF0MnFg7APVKPx+Gj1XyGbaBzQkBMAkeuVy7bapjhCvAxH XkG1SPS+vxeq8BgqlJCrUAh/0yC97Ghus0C0qHhYvxgs6CwZ+L1GzMhxDAzJu+J+i4n0 fEEU9lVETQIMoFmZmNF815oHBkS4Bh7cHHd9cW7Y0Gria/n8pHWXbIjP6+qYqHC7kuT9 ECk4g3mCFKmko1KiD9dzSYVVZAa/0ZqNE381571+NVIlgeParHTZ/txMSGFt2TnHdyvJ NY02QZu98kFhhFw/JpeoP2ew5tLsuZ6bO+9rcTiArN5J48lmWYnTejEWfw5P0JQ+cabZ OwRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m16si14947681plk.258.2017.11.13.11.37.39; Mon, 13 Nov 2017 11:37:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754699AbdKMTg4 (ORCPT + 87 others); Mon, 13 Nov 2017 14:36:56 -0500 Received: from gateway32.websitewelcome.com ([192.185.145.107]:25200 "EHLO gateway32.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754538AbdKMTgz (ORCPT ); Mon, 13 Nov 2017 14:36:55 -0500 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 17F3F2BA23B for ; Mon, 13 Nov 2017 13:36:54 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id EKXOeLzRkRtUXEKXOeVyMQ; Mon, 13 Nov 2017 13:36:54 -0600 Received: from [189.175.248.21] (port=38628 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1eEKXN-001wVM-Da; Mon, 13 Nov 2017 13:36:53 -0600 Date: Mon, 13 Nov 2017 13:36:50 -0600 From: "Gustavo A. R. Silva" To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] nvme: host: core: fix NULL pointer dereference in nvme_pr_command Message-ID: <20171113193650.GA2832@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.248.21 X-Source-L: No X-Exim-ID: 1eEKXN-001wVM-Da X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.175.248.21]:38628 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 6 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org _head_ pointer is being dereferenced when it is NULL. Fix this by moving the code that dereferences such pointer after it has been properly initialized in function nvme_get_ns_from_disk. Addresses-Coverity-ID: 1461344 Fixes: 32acab3181c7 ("nvme: implement multipath access to nvme subsystems") Signed-off-by: Gustavo A. R. Silva --- drivers/nvme/host/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 25da74d..9b9c324 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1452,16 +1452,16 @@ static int nvme_pr_command(struct block_device *bdev, u32 cdw10, put_unaligned_le64(key, &data[0]); put_unaligned_le64(sa_key, &data[8]); - memset(&c, 0, sizeof(c)); - c.common.opcode = op; - c.common.nsid = cpu_to_le32(head->ns_id); - c.common.cdw10[0] = cpu_to_le32(cdw10); - ns = nvme_get_ns_from_disk(bdev->bd_disk, &head, &srcu_idx); - if (unlikely(!ns)) + if (unlikely(!ns)) { ret = -EWOULDBLOCK; - else + } else { + memset(&c, 0, sizeof(c)); + c.common.opcode = op; + c.common.nsid = cpu_to_le32(head->ns_id); + c.common.cdw10[0] = cpu_to_le32(cdw10); ret = nvme_submit_sync_cmd(ns->queue, &c, data, 16); + } nvme_put_ns_from_disk(head, srcu_idx); return ret; } -- 2.7.4 From 1586141811406522826@xxx Thu Dec 07 16:05:07 +0000 2017 X-GM-THRID: 1585578147945900926 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread