Skip to content

Commit

Permalink
tpm: missing tpm_chip_put in tpm_get_random()
Browse files Browse the repository at this point in the history
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: <[email protected]> # 3.7+
Signed-off-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
  • Loading branch information
Jarkko Sakkinen authored and PeterHuewe committed Jul 29, 2014
1 parent b49e104 commit 3e14d83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -991,13 +991,13 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
int err, total = 0, retries = 5;
u8 *dest = out;

if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
return -EINVAL;

chip = tpm_chip_find_get(chip_num);
if (chip == NULL)
return -ENODEV;

if (!out || !num_bytes || max > TPM_MAX_RNG_DATA)
return -EINVAL;

do {
tpm_cmd.header.in = tpm_getrandom_header;
tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes);
Expand All @@ -1016,6 +1016,7 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max)
num_bytes -= recd;
} while (retries-- && total < max);

tpm_chip_put(chip);
return total ? total : -EIO;
}
EXPORT_SYMBOL_GPL(tpm_get_random);
Expand Down

0 comments on commit 3e14d83

Please sign in to comment.