Message ID | 1488839535-11822-1-git-send-email-honclo@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <tpmdd-devel-bounces@lists.sourceforge.net> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40654601D2 for <patchwork-tpmdd-devel@patchwork.kernel.org>; Mon, 6 Mar 2017 22:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8643428484 for <patchwork-tpmdd-devel@patchwork.kernel.org>; Mon, 6 Mar 2017 22:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B06828487; Mon, 6 Mar 2017 22:32:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E31DD28484 for <patchwork-tpmdd-devel@patchwork.kernel.org>; Mon, 6 Mar 2017 22:32:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from <tpmdd-devel-bounces@lists.sourceforge.net>) id 1cl1BG-0002HA-W5; Mon, 06 Mar 2017 22:32:38 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from <honclo@linux.vnet.ibm.com>) id 1cl1BF-0002H4-IJ for tpmdd-devel@lists.sourceforge.net; Mon, 06 Mar 2017 22:32:37 +0000 X-ACL-Warn: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cl1BD-0000Hz-CX for tpmdd-devel@lists.sourceforge.net; Mon, 06 Mar 2017 22:32:37 +0000 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v26MT7Tp088943 for <tpmdd-devel@lists.sourceforge.net>; Mon, 6 Mar 2017 17:32:29 -0500 Received: from e28smtp06.in.ibm.com (e28smtp06.in.ibm.com [125.16.236.6]) by mx0b-001b2d01.pphosted.com with ESMTP id 2917muj20j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for <tpmdd-devel@lists.sourceforge.net>; Mon, 06 Mar 2017 17:32:29 -0500 Received: from localhost by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for <tpmdd-devel@lists.sourceforge.net> from <honclo@linux.vnet.ibm.com>; Tue, 7 Mar 2017 04:02:26 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Mar 2017 04:02:24 +0530 Received: from d28relay08.in.ibm.com (d28relay08.in.ibm.com [9.184.220.159]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 32EE7125804F for <tpmdd-devel@lists.sourceforge.net>; Tue, 7 Mar 2017 04:02:39 +0530 (IST) Received: from d28av07.in.ibm.com (d28av07.in.ibm.com [9.184.220.146]) by d28relay08.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v26MVFsG11600112 for <tpmdd-devel@lists.sourceforge.net>; Tue, 7 Mar 2017 04:01:15 +0530 Received: from d28av07.in.ibm.com (localhost [127.0.0.1]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v26MWMWZ012523 for <tpmdd-devel@lists.sourceforge.net>; Tue, 7 Mar 2017 04:02:23 +0530 Received: from vtpm2014.ibm.com ([9.85.180.86]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v26MWIBR012515; Tue, 7 Mar 2017 04:02:19 +0530 From: "Hon Ching(Vicky) Lo" <honclo@linux.vnet.ibm.com> To: tpmdd-devel@lists.sourceforge.net Date: Mon, 6 Mar 2017 17:32:15 -0500 X-Mailer: git-send-email 1.7.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030622-0020-0000-0000-000000C9E845 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030622-0021-0000-0000-0000028839F5 Message-Id: <1488839535-11822-1-git-send-email-honclo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-06_22:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703060179 X-Headers-End: 1cl1BD-0000Hz-CX Cc: Ashley Lai <ashley@ashleylai.com>, linux-kernel@vger.kernel.org, "Hon Ching\(Vicky\) Lo" <honclo@linux.vnet.ibm.com>, stable@vger.kernel.org, Peter Huewe <PeterHuewe@gmx.de> Subject: [tpmdd-devel] [PATCH] vTPM: Fix missing NULL check X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance <tpmdd-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/tpmdd-devel>, <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=tpmdd-devel> List-Post: <mailto:tpmdd-devel@lists.sourceforge.net> List-Help: <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/tpmdd-devel>, <mailto:tpmdd-devel-request@lists.sourceforge.net?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c index 1b9d61f..a88ee25 100644 --- a/drivers/char/tpm/tpm_ibmvtpm.c +++ b/drivers/char/tpm/tpm_ibmvtpm.c @@ -313,7 +313,10 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev) static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev) { struct tpm_chip *chip = dev_get_drvdata(&vdev->dev); - struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); + struct ibmvtpm_dev *ibmvtpm = NULL; + + if (chip) + ibmvtpm = dev_get_drvdata(&chip->dev); /* * ibmvtpm initializes at probe time, so the data we are
The current code passes the address of tpm_chip as the argument to dev_get_drvdata() without prior NULL check in tpm_ibmvtpm_get_desired_dma. This resulted an oops during kernel boot when vTPM is enabled in Power partition configured in active memory sharing mode. The vio_driver's get_desired_dma() is called before the probe(), which for vtpm is tpm_ibmvtpm_probe, and it's this latter function that initializes the driver and set data. Attempting to get data before the probe() caused the problem. This patch adds a NULL check to the tpm_ibmvtpm_get_desired_dma. fixes: 9e0d39d8a6a0 ("tpm: Remove useless priv field in struct tpm_vendor_specific") Cc: <stable@vger.kernel.org> Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com> --- drivers/char/tpm/tpm_ibmvtpm.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)