From patchwork Wed Nov 28 17:29:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152336 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1365473ljp; Wed, 28 Nov 2018 09:29:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7iRtd2PsfjISuvHkg6qQ40eA2II8wGJVO+2C1ynK9Nzviv2OknQWcAIR9omyrRQeb36g4 X-Received: by 2002:a17:902:a98c:: with SMTP id bh12mr1504332plb.31.1543426193454; Wed, 28 Nov 2018 09:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543426193; cv=none; d=google.com; s=arc-20160816; b=KPv3W0UkwwoloMFPWvz3jvnjo9DvdwuV/aca2UYQwtBi5Az19zcJ1ePFzHqTdVjjfZ xdZZXnGZm1EPXz8ci9qicHr5yLkfsYVH5jKDF/KEdbBcMD0xeJuSmDSxbRFF9Mn1MDUd Yyor+/liNEn0v0nORVEk1utvXrEyi4DlPs7nbMXCNf6jBNE4wmLJuS0bTWMTvrgPpy7m pXeJ8V9nuCiDcf93MD27AAZDgkGVEB5SZXWkBnKO/0W3Q3z/Viq3Iz4asri3GWJAdaIb WL2KRdG5WKTrmDviq4RX8u9ND6qG9KDaLUGlVg4+OJpIez+O7gMLOiz1wuj1Dt0TP/FP dLvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Tv+VMU/fdIkd9+az64ZS9UaXO8LTOU3YtYa3BKSR1yY=; b=qUTyMnfggsIJTWx//pZppLEq871JhdfmNtRTtK/kVbD9X+4XGgIGhFUtsvxcBHHVDr cMv5zl/SpWk1DTNSr/pWA2obyBYC/ljKAG//H1p0tzS/vX8ZK60cMzRv2lsxImWUcfMk 7P9U/hPjm1yMiWAIVkz1h9KaIz7E1NPOm8IL6c4hll5z28kaLhHixGPQsy7KMq0HBa8b pZK9MIy+dVfHCjMTlAw2M6c6YxDoKGLLzwOCxZmeqGdWKrI6nz1Val1ky2dqg9ElTCX/ bzKI2uW0kaRmlIwdxbiGdvPmHuThxVuuSc5rBNA0Cphfw78wks7GLVFVrBsqXHTAXOvD iaOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZU23Vr0i; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si8357481plb.57.2018.11.28.09.29.51; Wed, 28 Nov 2018 09:29:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZU23Vr0i; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729264AbeK2EcB (ORCPT + 15 others); Wed, 28 Nov 2018 23:32:01 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42240 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728851AbeK2EcA (ORCPT ); Wed, 28 Nov 2018 23:32:00 -0500 Received: by mail-pg1-f195.google.com with SMTP id d72so9785863pga.9 for ; Wed, 28 Nov 2018 09:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tv+VMU/fdIkd9+az64ZS9UaXO8LTOU3YtYa3BKSR1yY=; b=ZU23Vr0i897xMZd6BysUfqCtfPVHY2y2N7aLkLaifz5c+V1CyrTNMI2Q6tQXUfFsFC voO317m2v/XATPEc+qnRv/NTTg66RXA41FNQ6R70SAE5yQFM9mj9EYrJXk6slSZOGPDe aWwqr5qBXwLtobZf45nvt7Fvc21nDub8jaRZg= 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=Tv+VMU/fdIkd9+az64ZS9UaXO8LTOU3YtYa3BKSR1yY=; b=Qa89sh9q8j+rA18frXi3vUiMouUQC9YSW5WdFLewF1y06cDDGVUmmF7QfxekX78hdf 0EkBrW4Amauj1IO/37qdPAm0MAAg1O81LJT2xCFGlrJKw9WV6iDm+LObFx50+HbsvSqk eG1Jd1xB7liLUGg5FSpZCfvu+S6Lo0iCzLK4ypnKHoTp7sI0dpLKX0q/DUxXdznsUus4 qXZfNgCO5RbjKk4GjExbdhoZW75TlKp2JLdWRdx4pWzkbo26L9rOLbnT1a2dOFn+SzrS iIoRSS7Rn5Ys7G3adSoIxIsQE6Vx8wOyYKR5woQ/oqTQuEDRuP3wDOo11EWXbcQwzgpB FCgA== X-Gm-Message-State: AGRZ1gJiWc1WSso1DPS6Rg01assByiHQcD0j8noaH5IyedW8A4ZTo3xj 1HnX/r3a3dJKvw0Qu6pe36Aasg== X-Received: by 2002:a62:8a51:: with SMTP id y78mr37900029pfd.35.1543426177631; Wed, 28 Nov 2018 09:29:37 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id 84sm13624360pfk.134.2018.11.28.09.29.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 09:29:36 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Mauricio Faria de Oliveira , "Martin K . Petersen" Subject: [PATCH for-4.4.y 09/10] scsi: qla2xxx: do not queue commands when unloading Date: Wed, 28 Nov 2018 22:59:08 +0530 Message-Id: <1543426149-7269-10-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> References: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mauricio Faria de Oliveira commit 04dfaa53a0b6e66b328a5bc549e3af8f8b6eac02 upstream. When the driver is unloading, in qla2x00_remove_one(), there is a single call/point in time to abort ongoing commands, qla2x00_abort_all_cmds(), which is still several steps away from the call to scsi_remove_host(). If more commands continue to arrive and be processed during that interval, when the driver is tearing down and releasing its structures, it might potentially hit an oops due to invalid memory access: Unable to handle kernel paging request for data at address 0x00000138 <...> NIP [d000000004700a40] qla2xxx_queuecommand+0x80/0x3f0 [qla2xxx] LR [d000000004700a10] qla2xxx_queuecommand+0x50/0x3f0 [qla2xxx] So, fail commands in qla2xxx_queuecommand() if the UNLOADING bit is set. Signed-off-by: Mauricio Faria de Oliveira Acked-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Amit Pundir --- drivers/scsi/qla2xxx/qla_os.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 18b19744398a..ff5df33fc740 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -685,6 +685,11 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) srb_t *sp; int rval; + if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { + cmd->result = DID_NO_CONNECT << 16; + goto qc24_fail_command; + } + if (ha->flags.eeh_busy) { if (ha->flags.pci_channel_io_perm_failure) { ql_dbg(ql_dbg_aer, vha, 0x9010,