[Skiboot] [PATCH] tpm_i2c_nuvoton: check TPM vendor id register during probe

Klaus Heinrich Kiwi klaus at linux.vnet.ibm.com
Fri Mar 6 08:16:42 AEDT 2020



On 3/5/2020 3:54 PM, Eric Richter wrote:
> +		/* ensure there's really the TPM we expect at that address */
> +		if (tpm_i2c_request_send(tpm_device, SMBUS_READ, TPM_VID_DID,
> +					 1, &vendor, sizeof(vendor)) ||
> +		    (vendor & TPM_VENDOR_ID_MASK) != TPM_650_VENDOR_ID) {
if tpm_i2c_request_send() fails (negative error code), you skip this 
block and still tries to tpm_register_chip()?

> +			prlog(PR_ERR, "NUVOTON: i2c device inaccessible, or "
> +			      "expected vendor id mismatch\n");
> +			if (vendor) {
> +				prlog(PR_ERR, "NUVOTON: expected 0x%X, "
> +				      "got 0x%X\n", TPM_650_VENDOR_ID, vendor);
> +			}
> +			free(tpm_device);
> +			continue;
> +		}
>   		if (tpm_register_chip(node, tpm_device,
>   				      &tpm_i2c_nuvoton_driver)) {
>   			free(tpm_device);
> 

Perhaps registering it would then fail? Since tpm_register_chip() sounds 
both like an action as well as a predicate, perhaps be more explicit 
about what we are testing? (I know this is outside the proposed patch 
but still...)

  -Klaus

-- 
Klaus Heinrich Kiwi <klaus at linux.vnet.ibm.com>


More information about the Skiboot mailing list