aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHon Ching (Vicky) Lo <honclo@linux.vnet.ibm.com>2014-11-30 15:01:28 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-06 14:43:29 -0800
commit2a360130c4f6fe4478a34b3e324472b44ebd0e73 (patch)
tree3950dba5205315c6094616a8628206bb86231dd5
parent16ee72e909d0dc79951daf531698d1e241388e29 (diff)
downloadlinux-yocto-2a360130c4f6fe4478a34b3e324472b44ebd0e73.tar.gz
linux-yocto-2a360130c4f6fe4478a34b3e324472b44ebd0e73.tar.bz2
linux-yocto-2a360130c4f6fe4478a34b3e324472b44ebd0e73.zip
tpm: Fix NULL return in tpm_ibmvtpm_get_desired_dma
commit 84eb186bc37c0900b53077ca21cf6dd15823a232 upstream. There was an oops in tpm_ibmvtpm_get_desired_dma, which caused kernel panic during boot when vTPM is enabled in Power partition configured in AMS mode. vio_bus_probe calls vio_cmo_bus_probe which calls tpm_ibmvtpm_get_desired_dma to get the size needed for DMA allocation. The problem is, vio_cmo_bus_probe is called before calling probe, which for vtpm is tpm_ibmvtpm_probe and it's this function that initializes and sets up vtpm's CRQ and gets required data values. Therefore, since this has not yet been done, NULL is returned in attempt to get the size for DMA allocation. We added a NULL check. In addition, a default buffer size will be set when NULL is returned. Signed-off-by: Hon Ching (Vicky) Lo <honclo@linux.vnet.ibm.com> Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/char/tpm/tpm_ibmvtpm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index af74c57e5090..4109222f2878 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -307,6 +307,14 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
{
struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
+
+ /* ibmvtpm initializes at probe time, so the data we are
+ * asking for may not be set yet. Estimate that 4K required
+ * for TCE-mapped buffer in addition to CRQ.
+ */
+ if (!ibmvtpm)
+ return CRQ_RES_BUF_SIZE + PAGE_SIZE;
+
return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size;
}