From patchwork Wed Oct 10 09:29:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 148547 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp617437lji; Wed, 10 Oct 2018 02:30:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV61uUOMFKXXu1xdl9OWIRVrlwHtppQTtVyWtGSxdl7fbbCo9KCQZ+IhA1cT085BkQRmJLohl X-Received: by 2002:a17:902:16a4:: with SMTP id h33-v6mr24699192plh.3.1539163804849; Wed, 10 Oct 2018 02:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539163804; cv=none; d=google.com; s=arc-20160816; b=BG55jPBzWxJaKpaf1kHgxjHA0Q1XVhLNXLlrE3+pZFclD0GsEaYqZAVjqpMAws0D3r jHBW1x1KDDolaeGzb5jM3HCn+MG0h2husNki4jAHBUei3UbILYTKkMbSs2XhrzWWDqZB iYtM0mMfvjGkTGEjXRNkpVbTOkaTQcUGaUYjrDIbTtWArOhoKwBjwL2a1/v5P/koudbT LjOP6TLoN+F4BwmPl1NvnCNgkwRI8XfVAb/H9qt4dq1mxeJzx6IWzEA+LU7J8f2IYY2P 9r2CvyOMgrEXFdJdUmiqDA5vKC4pBImbBc9szcl5VfVPvp3GeSx+T499Ep7ScjRV5jf2 yWAQ== 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=y+PDdsHHh+P9RHRQlEHLjCkh9tUozsbI5JNl7NI13zI=; b=b9T4zG9P5XFPaLoeRUdPELIlvX8t4cQf70RJCfJ1sat5YW3/LZgyRJuM/Yrwtazg/r b6K3fA3v1enGdYHW/1o9bvLneKv8Poc5b834qiQO+xZzxHpsibcgZlhzEydXN+9sJmrE JPS65GxPm6dr/9cjdsahjU6MCsXLcGMIWklsnYp6GRQ/bMh42U8VQfO7enuaRrf/al4+ HybAfvNM4i/CaLAkzTubJXo8NaYaPpGJ+AePXUVzRiFMZOWxTe364U0UP0rVSIml2gHG mZFb1ICIH3OtXmSwJM53od7YbIh8OHPgYfk6TYXSXko9NMh+ZoZ/IngRNpZoSEhAd136 wANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=agRNH3FO; 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 o12-v6si27119281pfd.102.2018.10.10.02.30.04; Wed, 10 Oct 2018 02:30:04 -0700 (PDT) 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=agRNH3FO; 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 S1726830AbeJJQvW (ORCPT + 14 others); Wed, 10 Oct 2018 12:51:22 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38008 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbeJJQvW (ORCPT ); Wed, 10 Oct 2018 12:51:22 -0400 Received: by mail-pl1-f194.google.com with SMTP id b5-v6so2254000plr.5 for ; Wed, 10 Oct 2018 02:30:03 -0700 (PDT) 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=y+PDdsHHh+P9RHRQlEHLjCkh9tUozsbI5JNl7NI13zI=; b=agRNH3FOZoUieGNK7NWVs2O8+EQndrlx6GOBOMnyKA6fwX4tbDB1n5p8W8RNhZXD4F OSl0mAOJK5GHvwr5EgX8qSCElvN8c+W8aA9zq0KkC/zGZiIxE3dvg/rFhh7Qo1I0oTBo BLxUCy3aXr3sBXoAm91KLyKBXmpJdyoNnlB7E= 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=y+PDdsHHh+P9RHRQlEHLjCkh9tUozsbI5JNl7NI13zI=; b=oDmHARJG8FBpAPyTAYWz1G8muN9P3ek/nYG1WeANsoYoWX3oU4lC1qwLhz/X4biWVu KIHSyhFQA5X7uLqmKVUPTfkoB8YfQVmxmwquPPo2twg5XywGHu2Wizov23QoUG7HSI+M SbWCR1VywurPbj2TMdf7In2ts7qlRLCgs23sdmb7FNnjPYrxWTM45y+Q/YBd9wK8982a Tp9/NAp4aLVDm2nmuC9BqSjNRn2/RFP4J1MxJtlYjqICKbw17eoQ8XETsWlq+teCjIRq Ick4IJjWegiYqpQELGt6Bj2SuNsqW1+iYEZp9xLBZ0Wa1m4t9vxy5ZvloaHdsgD0QelG 6P9A== X-Gm-Message-State: ABuFfojHKCTQPWZTHYbNubNWtGxEIKw2FBx7xkM2Kr5HUNFuKcI+JuEb tILPmofk46VARaT64p1VpYntkpmtwPs= X-Received: by 2002:a17:902:708b:: with SMTP id z11-v6mr8841336plk.151.1539163803111; Wed, 10 Oct 2018 02:30:03 -0700 (PDT) Received: from localhost.localdomain ([106.51.16.178]) by smtp.gmail.com with ESMTPSA id k71-v6sm37977548pge.44.2018.10.10.02.30.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Oct 2018 02:30:01 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , James Smart , James Smart , Keith Busch , Jens Axboe Subject: [PATCH for-4.14.y 4/4] nvme_fc: fix ctrl create failures racing with workq items Date: Wed, 10 Oct 2018 14:59:49 +0530 Message-Id: <1539163789-32338-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539163789-32338-1-git-send-email-amit.pundir@linaro.org> References: <1539163789-32338-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: James Smart commit cf25809bec2c7df4b45df5b2196845d9a4a3c89b upstream. If there are errors during initial controller create, the transport will teardown the partially initialized controller struct and free the ctlr memory. Trouble is - most of those errors can occur due to asynchronous events happening such io timeouts and subsystem connectivity failures. Those failures invoke async workq items to reset the controller and attempt reconnect. Those may be in progress as the main thread frees the ctrl memory, resulting in NULL ptr oops. Prevent this from happening by having the main ctrl failure thread changing state to DELETING followed by synchronously cancelling any pending queued work item. The change of state will prevent the scheduling of resets or reconnect events. Signed-off-by: James Smart Signed-off-by: Keith Busch Signed-off-by: Jens Axboe Signed-off-by: Amit Pundir --- Build tested on 4.14.74 for ARCH=arm/arm64 allmodconfig. drivers/nvme/host/fc.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 7deb7b5d8683..058d542647dd 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2868,6 +2868,10 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, } if (ret) { + nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); + cancel_work_sync(&ctrl->ctrl.reset_work); + cancel_delayed_work_sync(&ctrl->connect_work); + /* couldn't schedule retry - fail out */ dev_err(ctrl->ctrl.device, "NVME-FC{%d}: Connect retry failed\n", ctrl->cnum);