Skip to content

Commit 3e14d83

Browse files
Jarkko SakkinenPeterHuewe
authored andcommitted
tpm: missing tpm_chip_put in tpm_get_random()
Regression in 41ab999. Call to tpm_chip_put is missing. This will cause TPM device driver not to unload if tmp_get_random() is called. Cc: <stable@vger.kernel.org> # 3.7+ Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
1 parent b49e104 commit 3e14d83

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/char/tpm/tpm-interface.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,13 +991,13 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
991991
int err, total = 0, retries = 5;
992992
u8 *dest = out;
993993

994+
if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
995+
return -EINVAL;
996+
994997
chip = tpm_chip_find_get(chip_num);
995998
if (chip == NULL)
996999
return -ENODEV;
9971000

998-
if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
999-
return -EINVAL;
1000-
10011001
do {
10021002
tpm_cmd.header.in = tpm_getrandom_header;
10031003
tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes);
@@ -1016,6 +1016,7 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
10161016
num_bytes -= recd;
10171017
} while (retries-- && total < max);
10181018

1019+
tpm_chip_put(chip);
10191020
return total ? total : -EIO;
10201021
}
10211022
EXPORT_SYMBOL_GPL(tpm_get_random);

0 commit comments

Comments
 (0)