Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3589296pxb; Mon, 24 Jan 2022 12:58:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyaJcvqLT1apj20h/0G+TOP0Fxf50Sq4yT7Pem4nP6337bFjxRhZ44Wdt/e48aO+1rkPS5k X-Received: by 2002:a05:6a00:1946:b0:44d:8136:a4a4 with SMTP id s6-20020a056a00194600b0044d8136a4a4mr15417754pfk.46.1643057892007; Mon, 24 Jan 2022 12:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057892; cv=none; d=google.com; s=arc-20160816; b=0WSriijAhSJeuJPYro20/E55CkfT4Gyawjqb8kUjhMIxYUpPAbOtExrFZobCKg0cLK v/SREXsQVLLOBdPPZ5nvdNRQgFcuu6ejW3C3C+M8pofbNbYjt9WE8yjB6XPC5hrJZsYH SPoruvoRts/mS6VLQWSMCgRfBFEvXdUTQqEWI+Dc2c13o4mb3NkhmqJRblnkeOkI/DXF R/odq0JLvtEfAlNqpzeWYaJ92L8vezbg0IyuoU+uN4EYH7q/hMyltLH0t8Vit9AO2pJh fifIw+01XxoBLcCuSjE1oSACyheOyzvQ59RcoFEx/GmXy6iWxqCL5qNeDDdqcpFknkmI FOZQ== 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=GoziKx+2/PTJj+c79v33om+8iZRcEGArNGlhbb26oFc9H/ItmFvezmpOLmEuknl8xP t7gYTNmXLKDzN7syPiaGohEclKgqdHWb3LTIDE2BAlS1+AED4U2wPi9nV4PR7V7R2vVF X58+7u/HdHyGIJlTKcmXjLhZTs4TB0Fyt6F5OnqdHni5f48pb2RsxstL5MvgA32SiDVT Zo/RuAeIFDaCMdLPlb2pjK2IKPR342/r3gp3g7g5QS22cvpM8uBT2/JkFo+5KkFQh+QJ ayoTK8BccKwyLQlZH3MoSZ4h6eG6HfsCYvu/I6H2LwZznH2CTMvpb0TQswTy1DeCUWrR D1hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IXbm1vNF; 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 c8si16381694pgq.34.2022.01.24.12.57.59; Mon, 24 Jan 2022 12:58:11 -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=IXbm1vNF; 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 S1350534AbiAXUVp (ORCPT + 99 others); Mon, 24 Jan 2022 15:21:45 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:47728 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352290AbiAXUDd (ORCPT ); Mon, 24 Jan 2022 15:03:33 -0500 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 BDD7BB80FA1; Mon, 24 Jan 2022 20:03:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EED24C340E5; Mon, 24 Jan 2022 20:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643054610; bh=fKi7ZwPG8n0+BGVYMxk00IA52PoG1YjyUx5UZx1Vb/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXbm1vNFKuVxYVWc9sVbQQitjpL9vgq8DHgcCkIVWsXi4l3L+RRZSA+LSGTPYOH1+ itv4ZC6BtDEEymd18uCfk7TpiErh2DXdcHtjql/RVlZJNHz0gjB9UEFnV7gnNvz1Ac q4K5YLqwlrzlS5Lh8zjfvMNmmoIv3yxu1J0Ys9JI= 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.10 445/563] tpm: fix NPE on probe for missing device Date: Mon, 24 Jan 2022 19:43:30 +0100 Message-Id: <20220124184039.846941886@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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);