lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sun, 27 Nov 2022 19:21:39 +0200
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Hanjun Guo <guohanjun@...wei.com>
Cc:     Peter Huewe <peterhuewe@....de>, linux-integrity@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/3] tpm: tpm_tis: Add the missed acpi_put_table() to
 fix memory leak

On Thu, Nov 17, 2022 at 07:23:42PM +0800, Hanjun Guo wrote:
> In check_acpi_tpm2(), we get the TPM2 table just to make
> sure the table is there, not used after the init, so the
> acpi_put_table() should be added to release the ACPI memory.
> 
> Fixes: 4cb586a188d4 ("tpm_tis: Consolidate the platform and acpi probe flow")
> Cc: stable@...r.kernel.org
> Signed-off-by: Hanjun Guo <guohanjun@...wei.com>
> ---
>  drivers/char/tpm/tpm_tis.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index bcff642..ed5dabd 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -125,6 +125,7 @@ static int check_acpi_tpm2(struct device *dev)
>  	const struct acpi_device_id *aid = acpi_match_device(tpm_acpi_tbl, dev);
>  	struct acpi_table_tpm2 *tbl;
>  	acpi_status st;
> +	int ret = 0;
>  
>  	if (!aid || aid->driver_data != DEVICE_IS_TPM2)
>  		return 0;
> @@ -132,8 +133,7 @@ static int check_acpi_tpm2(struct device *dev)
>  	/* If the ACPI TPM2 signature is matched then a global ACPI_SIG_TPM2
>  	 * table is mandatory
>  	 */
> -	st =
> -	    acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl);
> +	st = acpi_get_table(ACPI_SIG_TPM2, 1, (struct acpi_table_header **)&tbl);
>  	if (ACPI_FAILURE(st) || tbl->header.length < sizeof(*tbl)) {
>  		dev_err(dev, FW_BUG "failed to get TPM2 ACPI table\n");
>  		return -EINVAL;
> @@ -141,9 +141,10 @@ static int check_acpi_tpm2(struct device *dev)
>  
>  	/* The tpm2_crb driver handles this device */
>  	if (tbl->start_method != ACPI_TPM2_MEMORY_MAPPED)
> -		return -ENODEV;
> +		ret = -ENODEV;
>  
> -	return 0;
> +	acpi_put_table((struct acpi_table_header *)tbl);
> +	return ret;
>  }
>  #else
>  static int check_acpi_tpm2(struct device *dev)
> -- 
> 1.7.12.4
> 

Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ