From patchwork Wed Nov 28 14:47:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152305 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1178825ljp; Wed, 28 Nov 2018 06:48:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdksPNaC+TIBdnWboIFXPdXFzOIlmv70LMnPxet2n+gV6CVnqCL+tluxZ0UUEU9bO4J4Wg X-Received: by 2002:a62:56c7:: with SMTP id h68mr10817055pfj.134.1543416486205; Wed, 28 Nov 2018 06:48:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416486; cv=none; d=google.com; s=arc-20160816; b=CpzQ1/s/nfVS3J2AZwMWHt5UFhA90S2cvo2/sMejepY9uC9okUfM0x4bpBAYMFindL RpsILr4sKBQEMAfW3rZWZs3AgJcOfWIBzq8RWOOrnhB3wTWhPRV7UzcgAziM9ARRIGzK GobcR4qhL4wzRP1JJQ/mLvaBa7NwE7kZhWlrZ0kMqJN6Ti8QqiCRDwOirwdpAlqbragk 5In4mHSRhh6AU0lVleVm6UQCez8mrmg5G3v4kOfAy7s7RHOlwjAxte8QXbR8RQF0KJYm VcgFua7fsOwkdarHKbZ+QD2KTovvFk4fjaeIZMDYYXT13d9kjRntKZ8a7Z+oakdvnKdN 1rCg== 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=visxGZMJguF0unhrb4VxL6DKUbvBzWjgQrcEmeTNHMg=; b=baCN8HD7iCI6AUYcjzn/WMV2mdYRy2sshkpyzCz08Zcc3uB794eqoCJPzGV4PqJDs9 ADxubWBWHWpRbrchKArgncWNoiJTP+WW4DJTL8/xFglJM1TV5t0XJKd9bs2jIbVMow0j KntNJdkvs7WZQdQI7Tgf0SbWA3eEgnWd+uzf4S7aq/4FoEzZFCj0CRl8jg/9zQaNUAe/ Atzb48BxhpBfxhgue9cug7uyufXfBmjYzaeSPiFqRTMmAni4n/J7zhoLXrd7rCO4BAGx Tjgy1kV3x8ba3cjvIrk1dfCklZw9PjyOo495tdO1BA13cfDgRKc2rUygLzdipHvlvIlE k2CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AOO7c2Pr; 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 p64si7857277pfa.94.2018.11.28.06.48.05; Wed, 28 Nov 2018 06:48:06 -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=AOO7c2Pr; 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 S1727726AbeK2Bt7 (ORCPT + 15 others); Wed, 28 Nov 2018 20:49:59 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44647 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728240AbeK2Bt7 (ORCPT ); Wed, 28 Nov 2018 20:49:59 -0500 Received: by mail-pl1-f194.google.com with SMTP id k8so6837534pls.11 for ; Wed, 28 Nov 2018 06:48:05 -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=visxGZMJguF0unhrb4VxL6DKUbvBzWjgQrcEmeTNHMg=; b=AOO7c2PrfXD/h1fW+RKnPr+2r4UyYA7L0Ig4h3AdAN125cgIkQLBsU6FKlV8aV4ohh 4I+1v0jQrQvTKtbWBZ8oNkgYuUimjEXCi0moh0KPX/ytiREDFGw+eWxWh5fAezsb4DLq rDrJ8yPphfql3JNsPY9gFtFKJ+ODYm4aQPDH8= 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=visxGZMJguF0unhrb4VxL6DKUbvBzWjgQrcEmeTNHMg=; b=by2q0ENYhkB7HKkS1Y01arz76NbrWOB1H71KAeSz0ed4pcVVr7ECI3EPtMhRWXwSbh OjxXYyhR/wAI3GMBc0/H30Z5Fjs6H/QlOjwtWIFhStqpCYDNyk/wnIqUKgTWIoJCsBVp CTqwAzkZm+FFApY0Mg8FYu1NUFQ6owwnFW9vvHw7Wdgy2ZxfQEaUCnHYxqywP6u3z4lp bhRIfE/y/7SvW1F8BpbeZgWjpCyDbPPhHAVHmzA2Aq5C2ublk7XMl2M1EtE+mFRjHYAZ vbQjampnXgYMH/oeKzbmadxCKCdW1fv+2cH4uR7eYIUIznKiposna0hsB76ks8CdnTub /ZqA== X-Gm-Message-State: AA+aEWYCubLDKwZ7LZU9M24qeXa4pnyimMvawVpXOT+iTvU9FjFmH8x2 psqeTg6XirHBbp/isjGe4gmmnw== X-Received: by 2002:a17:902:5a0b:: with SMTP id q11mr37575088pli.186.1543416484607; Wed, 28 Nov 2018 06:48:04 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id r80sm14295109pfa.111.2018.11.28.06.48.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 06:48:03 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Mauricio Faria de Oliveira , "Martin K . Petersen" Subject: [PATCH for-3.18.y 5/5] scsi: qla2xxx: do not queue commands when unloading Date: Wed, 28 Nov 2018 20:17:47 +0530 Message-Id: <1543416467-2081-6-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543416467-2081-1-git-send-email-amit.pundir@linaro.org> References: <1543416467-2081-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 7bc28c8d2832..4bd4f185102e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -687,6 +687,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,