Skip to content

Commit 5d8e297

Browse files
joehattorijarkkojs
authored andcommitted
char: tpm: Fix possible memory leak in tpm_bios_measurements_open()
In tpm_bios_measurements_open(), get_device() is called on the device embedded in struct tpm_chip. In the error path, however, put_device() is not called. This results in a reference count leak, which prevents the device from being properly released. This commit makes sure to call put_device() when the seq_open() call fails. Cc: [email protected] # +v4.18 Fixes: 9b01b53 ("tpm: Move shared eventlog functions to common.c") Signed-off-by: Joe Hattori <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 22a40d1 commit 5d8e297

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/char/tpm/eventlog/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static int tpm_bios_measurements_open(struct inode *inode,
4747
if (!err) {
4848
seq = file->private_data;
4949
seq->private = chip;
50+
} else {
51+
put_device(&chip->dev);
5052
}
5153

5254
return err;

0 commit comments

Comments
 (0)