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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 26 Jun 2018 14:36:13 -0400
From:   Stefan Berger <stefanb@...ux.vnet.ibm.com>
To:     linux-integrity@...r.kernel.org, jarkko.sakkinen@...ux.intel.com,
        zohar@...ux.vnet.ibm.com
Cc:     jgg@...pe.ca, linux-kernel@...r.kernel.org,
        linux-security-module@...r.kernel.org
Subject: Re: [PATCH v6 3/5] tpm: Convert tpm_find_get_ops() to use
 tpm_default_chip()

On 06/26/2018 01:23 PM, Stefan Berger wrote:
> Convert tpm_find_get_ops() to use tpm_default_chip() in case no chip
> is passed in.
>
> Signed-off-by: Stefan Berger <stefanb@...ux.vnet.ibm.com>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
> ---
>   drivers/char/tpm/tpm-chip.c | 32 +++++++++++++-------------------
>   1 file changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index f551061262c9..b01d34983766 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -124,29 +124,23 @@ EXPORT_SYMBOL_GPL(tpm_default_chip);
>    */
>   struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip)
>   {
> -	struct tpm_chip *res = NULL;
> -	int chip_num = 0;
> -	int chip_prev;
> -
> -	mutex_lock(&idr_lock);
> +	int rc;
>
> -	if (!chip) {
> -		do {
> -			chip_prev = chip_num;
> -			chip = idr_get_next(&dev_nums_idr, &chip_num);
> -			if (chip && !tpm_try_get_ops(chip)) {
> -				res = chip;
> -				break;
> -			}
> -		} while (chip_prev != chip_num);
> -	} else {
> +	if (chip) {
>   		if (!tpm_try_get_ops(chip))
> -			res = chip;
> +			return chip;
> +		return NULL;
>   	}
>
> -	mutex_unlock(&idr_lock);
> -
> -	return res;
> +	chip = tpm_default_chip();
> +	if (!chip)
> +		return NULL;
> +	rc = tpm_try_get_ops(chip);
> +	/* release additional reference we got from tpm_default_chip() */
> +	put_device(&chip->dev);
> +	if (!rc)
This should say 'if (rc)'.
> +		return NULL;
> +	return chip;
>   }
>
>   /**


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ