From patchwork Thu May 31 10:34:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitra P B X-Patchwork-Id: 10440671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3775B602BD for ; Thu, 31 May 2018 10:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A1E62921A for ; Thu, 31 May 2018 10:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E6202922D; Thu, 31 May 2018 10:35:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEFFE29223 for ; Thu, 31 May 2018 10:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754521AbeEaKfU (ORCPT ); Thu, 31 May 2018 06:35:20 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:37935 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754506AbeEaKfS (ORCPT ); Thu, 31 May 2018 06:35:18 -0400 Received: by mail-qt0-f194.google.com with SMTP id x34-v6so13937488qtk.5 for ; Thu, 31 May 2018 03:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L/PqNLv7L2zjXoOQJHkMwogLzTVeEJws66apF70K1vY=; b=hWSX5wiVX8l3F+jbU0YgtuOXzjI6qprP2eYyb72Pm7oioKYQoX4GBNRaIgXuDVIgM5 yw6fb6pMl1y/5CXqmOCrnJS/6MRNvXWDePcAvQG17nb7stwIOr+Lrg3dQjEsg3XW+1Qi MTTSfWpJXCdPFFGsgN3Qq+GhDkcre0vM4XNY0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L/PqNLv7L2zjXoOQJHkMwogLzTVeEJws66apF70K1vY=; b=aqcH0IT+qhUcYF+zUJDuNlxWHz+jltLVpF5vjvHFadrlWtHtgPLDgfpTzqX+3pBh4y BTsc01oZWfx7Mnl7wQKS780UUTQk+6rzW1bWNlGju4zg9nyf2HP9/pA8YKolUrJrdK/p KcrqAqY549cuxPZ5+lNrr/mHdgftXAELAGYTEuXY4MIcHzJr6B2VkDMelH2EZT/ipg0T VrEQii5eQ7F+xitSadlS6Rnlq5j+glaiE3NFttehnnDlE2WZRbQxskW/gMt6X2lmGm84 YsBEjxm1wSX+T4nToasuhvdMhD1A6sre1YksXUxnZk1P6Inara3WhF9kLzKUE4IYghJb OHyw== X-Gm-Message-State: APt69E1Nl4Ng5D+yL6cknVT4k70MoxWld8YtI7NawMbUcwnqV92QcKnp nYh4+v4O8r822syvTD40y8PB337OUsQ= X-Google-Smtp-Source: ADUXVKI7fmKuyxYyVkaPEBnyVzQFA4TTjoO/DnYXD1myxD5T1GyJj0MMXDpVSgDYe1qpjC2DjlDrIg== X-Received: by 2002:ac8:fdb:: with SMTP id f27-v6mr6261978qtk.293.1527762917320; Thu, 31 May 2018 03:35:17 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n79-v6sm12661343qkn.84.2018.05.31.03.35.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 03:35:16 -0700 (PDT) From: Chaitra P B To: linux-scsi@vger.kernel.org Cc: sreekanth.reddy@broadcom.com, suganath-prabu.subramani@broadcom.com, sathya.prakash@broadcom.com, Chaitra P B Subject: [PATCH 3/6] mpt3sas: Don't access the structure after decrementing it's instance reference count. Date: Thu, 31 May 2018 06:34:49 -0400 Message-Id: <1527762892-3204-4-git-send-email-chaitra.basappa@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527762892-3204-1-git-send-email-chaitra.basappa@broadcom.com> References: <1527762892-3204-1-git-send-email-chaitra.basappa@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While configuring of NVMe device handling, _pcie_device structure member was accessed after its reference count is decremented/put. Hence modified code to access member of _pcie_device structure before its reference count is decremented/put. Signed-off-by: Chaitra P B --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 884878b..bf57827 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2365,13 +2365,14 @@ scsih_slave_configure(struct scsi_device *sdev) "connector name( %s)\n", ds, pcie_device->enclosure_level, pcie_device->connector_name); - pcie_device_put(pcie_device); - spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); - scsih_change_queue_depth(sdev, qdepth); if (pcie_device->nvme_mdts) blk_queue_max_hw_sectors(sdev->request_queue, pcie_device->nvme_mdts/512); + + pcie_device_put(pcie_device); + spin_unlock_irqrestore(&ioc->pcie_device_lock, flags); + scsih_change_queue_depth(sdev, qdepth); /* Enable QUEUE_FLAG_NOMERGES flag, so that IOs won't be ** merged and can eliminate holes created during merging ** operation.