Received: by 10.192.165.148 with SMTP id m20csp2537209imm; Sun, 22 Apr 2018 09:05:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+GQTg7kCjqrJcwLkqDQdT8tqTAZYL6zntFMGxjcfBOb9xMr1PzO0om57KvBFgGt9ju69GX X-Received: by 10.101.96.205 with SMTP id r13mr3033184pgv.22.1524413144618; Sun, 22 Apr 2018 09:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413144; cv=none; d=google.com; s=arc-20160816; b=voFe6hOK0EwlkSnUvBK5F877MasjlHWt7JAnUjVfs8CGbKd+4bxqWPvWTXelv9HFaM yXG/5P1v2+LEWuWAVH6ViT4Xx9y4tQgyiV+DU1F73hWfP7EgtyAeXGNbaEcrUt8UwZwl bEy5GgOov+UTO3CBuM8+7tg3Svij1JfEsz4lu+8UexGZRuDtvKWC/vyzZtYFe/hF3171 59cMRAh+deo+9VSHrgv9pTTgYNp3NgvQtPJnudsBeCDL2HYEsNP/Nraq4vYCQ9EycUdt Vcjy9VFgimFOxDpXHzDVsdQNpIXBg5AzoeL92Rplbh6ZI3bnUnP8rxKuZilZOVUx3NFT C6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zG0zLxCVwtMSzOXDDStKZvzga7myATr7BsYO0l1RvaM=; b=N3v1k/zNuv/7nFGR8iXENhBMuz6E5WOCFT2LgXiwt8N+I/DfS/w+lr9GPmmQ984KBD ZUS3Y1BZ+/hZfwQsI5MQgqFgsE7H8UcxecEnFBelQC5r6KjOGWA6n+JehwGBvu4pMRgA p+hCirCHC+ZdAs1nF57m04dfKPimjQZJOGfcDuJ+xC+rnpVjqp418VlIRpeBX4QKDSTa 0EQoQpF2S2942pvw6sK/QpC5svpOvsGn/+qFVbdR1xtpSi1U3zo2Pu9iu6BJGT1rDkSH /wNW5BG4uoJHlTlJhbru/E1W+BLEAvS3MTuDzPeTGmQmBoCKOpiXM6bnIbfi5NMTahEH PI2w== 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 l5-v6si4387304pli.409.2018.04.22.09.05.30; Sun, 22 Apr 2018 09:05:44 -0700 (PDT) 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 S1754207AbeDVQDZ (ORCPT + 99 others); Sun, 22 Apr 2018 12:03:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45992 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753578AbeDVN5z (ORCPT ); Sun, 22 Apr 2018 09:57:55 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D2A63CD5; Sun, 22 Apr 2018 13:57:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jordan Glover , Mika Westerberg , Yehezkel Bernat Subject: [PATCH 4.16 079/196] thunderbolt: Prevent crash when ICM firmware is not running Date: Sun, 22 Apr 2018 15:51:39 +0200 Message-Id: <20180422135108.378667088@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit ea9d7bb798900096f26c585957d6ad9c532417e6 upstream. On Lenovo ThinkPad Yoga 370 (and possibly some other Lenovo models as well) the Thunderbolt host controller sometimes comes up in such way that the ICM firmware is not running properly. This is most likely an issue in BIOS/firmware but as side-effect driver crashes the kernel due to NULL pointer dereference: BUG: unable to handle kernel NULL pointer dereference at 0000000000000980 IP: pci_write_config_dword+0x5/0x20 Call Trace: pcie2cio_write+0x3b/0x70 [thunderbolt] icm_driver_ready+0x168/0x260 [thunderbolt] ? tb_ctl_start+0x50/0x70 [thunderbolt] tb_domain_add+0x73/0xf0 [thunderbolt] nhi_probe+0x182/0x300 [thunderbolt] local_pci_probe+0x42/0xa0 ? pci_match_device+0xd9/0x100 pci_device_probe+0x146/0x1b0 driver_probe_device+0x315/0x480 ... Instead of crashing update the driver to bail out gracefully if we encounter such situation. Fixes: f67cf491175a ("thunderbolt: Add support for Internal Connection Manager (ICM)") Reported-by: Jordan Glover Signed-off-by: Mika Westerberg Acked-by: Yehezkel Bernat Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/thunderbolt/icm.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/thunderbolt/icm.c +++ b/drivers/thunderbolt/icm.c @@ -923,6 +923,9 @@ static int icm_firmware_reset(struct tb struct icm *icm = tb_priv(tb); u32 val; + if (!icm->upstream_port) + return -ENODEV; + /* Put ARC to wait for CIO reset event to happen */ val = ioread32(nhi->iobase + REG_FW_STS); val |= REG_FW_STS_CIO_RESET_REQ;