Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3678306pxb; Mon, 24 Jan 2022 15:08:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfDF0fOkxKhGnoU1yu3vjWYdVslX40jPdz0gYXIk6Xyv2URQxiA2gytP/XMDXdD1siQtq4 X-Received: by 2002:a63:8048:: with SMTP id j69mr10560335pgd.485.1643065704138; Mon, 24 Jan 2022 15:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065704; cv=none; d=google.com; s=arc-20160816; b=XGM7bF81RMBmRijMmd/Xxc/KeCv7dbqwbknyOR/BgChImfa4w+bGZkvrNUYI1bGkUP 8ec/Ifrz5hQesP9zMcd4/LTYcQT8w1Of1hjVBDLxkVRGm68xyOMwT0j6HSNUoYVFTQWh K2ntfKKt7SIeMiHAs5YiZ85198iMJ/YvpSj/jkpK3dZ21qfUij+AYyMNw9okrDl33GDG j626PsB2ApESQ92gTOerSIUPK4e6FfwscrwlttfW8+H44imMfV8T5b3FdUCWl/B5oNU7 pK9PG/B2LMq89oq7VYrMMpeHvd8JZUD4xnqW7uo42o3Hm/6fp/BPUX4p9w4rdr+Adf1i iucA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZxIeB9cdD54pWIr9t7gAsWdBvATQWjRc2eYJxjRNDr4=; b=Oku6ZePpO4CEO6zpQh6oQQz3nyeH97oOnrKTyD9pVCHjY6on9OPkOvLKHFQ3CHzNYb qK1y7p8V6J9NVU0lBLTcLqvGsMcVLjPgGwKY1iI4CccaWLDuTsu1CTTgG29TtkroYiVz 0PzQKEl7pQPIGW+1K1z4fUMGoVjEBBDBfrYYGS5oWmZtQmVR2dwpAOYr1SC1Eb+ZywyH Q7JU+rubr2WpwCRKzSVjUlgOzI+l5NCRo5Pnqrr07quJXElxSvnptXY5ow1r+iNprGG1 p6RXF6yM49Fi+qYNk1y37TsfiuQGtzWL6xRRk4XcFaI50z2t9WfGndhIIu8Etab751q5 mgBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbLoCf6W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t16si7423304plg.257.2022.01.24.15.08.12; Mon, 24 Jan 2022 15:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qbLoCf6W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843609AbiAXXFH (ORCPT + 99 others); Mon, 24 Jan 2022 18:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1581298AbiAXWLd (ORCPT ); Mon, 24 Jan 2022 17:11:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18B5DC0E03C9; Mon, 24 Jan 2022 12:43:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 90342B8105C; Mon, 24 Jan 2022 20:43:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0F31C340E5; Mon, 24 Jan 2022 20:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057016; bh=fKi7ZwPG8n0+BGVYMxk00IA52PoG1YjyUx5UZx1Vb/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qbLoCf6WI6Qbf6Df81SSBMp7RNMkXQkeT0T1GqWy9DMct2ZcnzdQwz8GNDc9QznnY EaMQSbf/8UrbIyA200lhTJFqXDVaJIwI0rVjIMXBAVd9FvVnW9I4WSewfZ6FRXWIgl FNmPavPysb2yOSEtJYqkE0e7NKH4g5/c+t1tLXQY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrick Williams , Jarkko Sakkinen Subject: [PATCH 5.15 674/846] tpm: fix NPE on probe for missing device Date: Mon, 24 Jan 2022 19:43:11 +0100 Message-Id: <20220124184124.324993444@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Patrick Williams commit 84cc69589700b90a4c8d27b481a51fce8cca6051 upstream. When using the tpm_tis-spi driver on a system missing the physical TPM, a null pointer exception was observed. [ 0.938677] Unable to handle kernel NULL pointer dereference at virtual address 00000004 [ 0.939020] pgd = 10c753cb [ 0.939237] [00000004] *pgd=00000000 [ 0.939808] Internal error: Oops: 5 [#1] SMP ARM [ 0.940157] CPU: 0 PID: 48 Comm: kworker/u4:1 Not tainted 5.15.10-dd1e40c #1 [ 0.940364] Hardware name: Generic DT based system [ 0.940601] Workqueue: events_unbound async_run_entry_fn [ 0.941048] PC is at tpm_tis_remove+0x28/0xb4 [ 0.941196] LR is at tpm_tis_core_init+0x170/0x6ac This is due to an attempt in 'tpm_tis_remove' to use the drvdata, which was not initialized in 'tpm_tis_core_init' prior to the first error. Move the initialization of drvdata earlier so 'tpm_tis_remove' has access to it. Signed-off-by: Patrick Williams Fixes: 79ca6f74dae0 ("tpm: fix Atmel TPM crash caused by too frequent queries") Cc: stable@vger.kernel.org Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm_tis_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -950,6 +950,8 @@ int tpm_tis_core_init(struct device *dev priv->timeout_max = TPM_TIMEOUT_USECS_MAX; priv->phy_ops = phy_ops; + dev_set_drvdata(&chip->dev, priv); + rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor); if (rc < 0) return rc; @@ -962,8 +964,6 @@ int tpm_tis_core_init(struct device *dev priv->timeout_max = TIS_TIMEOUT_MAX_ATML; } - dev_set_drvdata(&chip->dev, priv); - if (is_bsw()) { priv->ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR, ILB_REMAP_SIZE);