| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2014 Intel Corporation |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * This device driver implements the TPM interface as defined in |
|---|
| 10 | 11 | * the TCG CRB 2.0 TPM specification. |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or |
|---|
| 13 | | - * modify it under the terms of the GNU General Public License |
|---|
| 14 | | - * as published by the Free Software Foundation; version 2 |
|---|
| 15 | | - * of the License. |
|---|
| 16 | 12 | */ |
|---|
| 17 | 13 | |
|---|
| 18 | 14 | #include <linux/acpi.h> |
|---|
| .. | .. |
|---|
| 256 | 252 | iowrite32(CRB_LOC_CTRL_RELINQUISH, &priv->regs_h->loc_ctrl); |
|---|
| 257 | 253 | if (!crb_wait_for_reg_32(&priv->regs_h->loc_state, mask, value, |
|---|
| 258 | 254 | TPM2_TIMEOUT_C)) { |
|---|
| 259 | | - dev_warn(dev, "TPM_LOC_STATE_x.requestAccess timed out\n"); |
|---|
| 255 | + dev_warn(dev, "TPM_LOC_STATE_x.Relinquish timed out\n"); |
|---|
| 260 | 256 | return -ETIME; |
|---|
| 261 | 257 | } |
|---|
| 262 | 258 | |
|---|
| .. | .. |
|---|
| 680 | 676 | |
|---|
| 681 | 677 | /* Should the FIFO driver handle this? */ |
|---|
| 682 | 678 | sm = buf->start_method; |
|---|
| 683 | | - if (sm == ACPI_TPM2_MEMORY_MAPPED) |
|---|
| 684 | | - return -ENODEV; |
|---|
| 679 | + if (sm == ACPI_TPM2_MEMORY_MAPPED) { |
|---|
| 680 | + rc = -ENODEV; |
|---|
| 681 | + goto out; |
|---|
| 682 | + } |
|---|
| 685 | 683 | |
|---|
| 686 | 684 | priv = devm_kzalloc(dev, sizeof(struct crb_priv), GFP_KERNEL); |
|---|
| 687 | | - if (!priv) |
|---|
| 688 | | - return -ENOMEM; |
|---|
| 685 | + if (!priv) { |
|---|
| 686 | + rc = -ENOMEM; |
|---|
| 687 | + goto out; |
|---|
| 688 | + } |
|---|
| 689 | 689 | |
|---|
| 690 | 690 | if (sm == ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC) { |
|---|
| 691 | 691 | if (buf->header.length < (sizeof(*buf) + sizeof(*crb_smc))) { |
|---|
| .. | .. |
|---|
| 693 | 693 | FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", |
|---|
| 694 | 694 | buf->header.length, |
|---|
| 695 | 695 | ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC); |
|---|
| 696 | | - return -EINVAL; |
|---|
| 696 | + rc = -EINVAL; |
|---|
| 697 | + goto out; |
|---|
| 697 | 698 | } |
|---|
| 698 | 699 | crb_smc = ACPI_ADD_PTR(struct tpm2_crb_smc, buf, sizeof(*buf)); |
|---|
| 699 | 700 | priv->smc_func_id = crb_smc->smc_func_id; |
|---|
| .. | .. |
|---|
| 704 | 705 | |
|---|
| 705 | 706 | rc = crb_map_io(device, priv, buf); |
|---|
| 706 | 707 | if (rc) |
|---|
| 707 | | - return rc; |
|---|
| 708 | + goto out; |
|---|
| 708 | 709 | |
|---|
| 709 | 710 | chip = tpmm_chip_alloc(dev, &tpm_crb); |
|---|
| 710 | | - if (IS_ERR(chip)) |
|---|
| 711 | | - return PTR_ERR(chip); |
|---|
| 711 | + if (IS_ERR(chip)) { |
|---|
| 712 | + rc = PTR_ERR(chip); |
|---|
| 713 | + goto out; |
|---|
| 714 | + } |
|---|
| 712 | 715 | |
|---|
| 713 | 716 | dev_set_drvdata(&chip->dev, priv); |
|---|
| 714 | 717 | chip->acpi_dev_handle = device->handle; |
|---|
| 715 | 718 | chip->flags = TPM_CHIP_FLAG_TPM2; |
|---|
| 716 | 719 | |
|---|
| 717 | | - return tpm_chip_register(chip); |
|---|
| 720 | + rc = tpm_chip_register(chip); |
|---|
| 721 | + |
|---|
| 722 | +out: |
|---|
| 723 | + acpi_put_table((struct acpi_table_header *)buf); |
|---|
| 724 | + return rc; |
|---|
| 718 | 725 | } |
|---|
| 719 | 726 | |
|---|
| 720 | 727 | static int crb_acpi_remove(struct acpi_device *device) |
|---|