Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security

Pull tpm fixes from James Morris:
"fixes for the TPM driver"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
tpm: fix call order in tpm-chip.c
tpm/ibmvtpm: Additional LE support for tpm_ibmvtpm_send

+27 -33
+19 -25
drivers/char/tpm/tpm-chip.c
··· 140 140 { 141 141 int rc; 142 142 143 - rc = device_add(&chip->dev); 144 - if (rc) { 145 - dev_err(&chip->dev, 146 - "unable to device_register() %s, major %d, minor %d, err=%d\n", 147 - chip->devname, MAJOR(chip->dev.devt), 148 - MINOR(chip->dev.devt), rc); 149 - 150 - return rc; 151 - } 152 - 153 143 rc = cdev_add(&chip->cdev, chip->dev.devt, 1); 154 144 if (rc) { 155 145 dev_err(&chip->dev, ··· 148 158 MINOR(chip->dev.devt), rc); 149 159 150 160 device_unregister(&chip->dev); 161 + return rc; 162 + } 163 + 164 + rc = device_add(&chip->dev); 165 + if (rc) { 166 + dev_err(&chip->dev, 167 + "unable to device_register() %s, major %d, minor %d, err=%d\n", 168 + chip->devname, MAJOR(chip->dev.devt), 169 + MINOR(chip->dev.devt), rc); 170 + 151 171 return rc; 152 172 } 153 173 ··· 174 174 * tpm_chip_register() - create a character device for the TPM chip 175 175 * @chip: TPM chip to use. 176 176 * 177 - * Creates a character device for the TPM chip and adds sysfs interfaces for 178 - * the device, PPI and TCPA. As the last step this function adds the 179 - * chip to the list of TPM chips available for use. 177 + * Creates a character device for the TPM chip and adds sysfs attributes for 178 + * the device. As the last step this function adds the chip to the list of TPM 179 + * chips available for in-kernel use. 180 180 * 181 - * NOTE: This function should be only called after the chip initialization 182 - * is complete. 183 - * 184 - * Called from tpm_<specific>.c probe function only for devices 185 - * the driver has determined it should claim. Prior to calling 186 - * this function the specific probe function has called pci_enable_device 187 - * upon errant exit from this function specific probe function should call 188 - * pci_disable_device 181 + * This function should be only called after the chip initialization is 182 + * complete. 189 183 */ 190 184 int tpm_chip_register(struct tpm_chip *chip) 191 185 { 192 186 int rc; 193 - 194 - rc = tpm_dev_add_device(chip); 195 - if (rc) 196 - return rc; 197 187 198 188 /* Populate sysfs for TPM1 devices. */ 199 189 if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { ··· 197 207 198 208 chip->bios_dir = tpm_bios_log_setup(chip->devname); 199 209 } 210 + 211 + rc = tpm_dev_add_device(chip); 212 + if (rc) 213 + return rc; 200 214 201 215 /* Make the chip available. */ 202 216 spin_lock(&driver_lock);
+5 -5
drivers/char/tpm/tpm_ibmvtpm.c
··· 124 124 { 125 125 struct ibmvtpm_dev *ibmvtpm; 126 126 struct ibmvtpm_crq crq; 127 - u64 *word = (u64 *) &crq; 127 + __be64 *word = (__be64 *)&crq; 128 128 int rc; 129 129 130 130 ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip); ··· 145 145 memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); 146 146 crq.valid = (u8)IBMVTPM_VALID_CMD; 147 147 crq.msg = (u8)VTPM_TPM_COMMAND; 148 - crq.len = (u16)count; 149 - crq.data = ibmvtpm->rtce_dma_handle; 148 + crq.len = cpu_to_be16(count); 149 + crq.data = cpu_to_be32(ibmvtpm->rtce_dma_handle); 150 150 151 - rc = ibmvtpm_send_crq(ibmvtpm->vdev, cpu_to_be64(word[0]), 152 - cpu_to_be64(word[1])); 151 + rc = ibmvtpm_send_crq(ibmvtpm->vdev, be64_to_cpu(word[0]), 152 + be64_to_cpu(word[1])); 153 153 if (rc != H_SUCCESS) { 154 154 dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); 155 155 rc = 0;
+3 -3
drivers/char/tpm/tpm_ibmvtpm.h
··· 22 22 struct ibmvtpm_crq { 23 23 u8 valid; 24 24 u8 msg; 25 - u16 len; 26 - u32 data; 27 - u64 reserved; 25 + __be16 len; 26 + __be32 data; 27 + __be64 reserved; 28 28 } __attribute__((packed, aligned(8))); 29 29 30 30 struct ibmvtpm_crq_queue {