aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tpm/tpm_bios.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index aedf7a8e6da7..9ffa5643e79d 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -487,26 +487,35 @@ struct file_operations tpm_binary_bios_measurements_ops = {
487 .release = tpm_bios_measurements_release, 487 .release = tpm_bios_measurements_release,
488}; 488};
489 489
490static int is_bad(void *p)
491{
492 if (!p)
493 return 1;
494 if (IS_ERR(p) && (PTR_ERR(p) != -ENODEV))
495 return 1;
496 return 0;
497}
498
490struct dentry **tpm_bios_log_setup(char *name) 499struct dentry **tpm_bios_log_setup(char *name)
491{ 500{
492 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file; 501 struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
493 502
494 tpm_dir = securityfs_create_dir(name, NULL); 503 tpm_dir = securityfs_create_dir(name, NULL);
495 if (!tpm_dir) 504 if (is_bad(tpm_dir))
496 goto out; 505 goto out;
497 506
498 bin_file = 507 bin_file =
499 securityfs_create_file("binary_bios_measurements", 508 securityfs_create_file("binary_bios_measurements",
500 S_IRUSR | S_IRGRP, tpm_dir, NULL, 509 S_IRUSR | S_IRGRP, tpm_dir, NULL,
501 &tpm_binary_bios_measurements_ops); 510 &tpm_binary_bios_measurements_ops);
502 if (!bin_file) 511 if (is_bad(bin_file))
503 goto out_tpm; 512 goto out_tpm;
504 513
505 ascii_file = 514 ascii_file =
506 securityfs_create_file("ascii_bios_measurements", 515 securityfs_create_file("ascii_bios_measurements",
507 S_IRUSR | S_IRGRP, tpm_dir, NULL, 516 S_IRUSR | S_IRGRP, tpm_dir, NULL,
508 &tpm_ascii_bios_measurements_ops); 517 &tpm_ascii_bios_measurements_ops);
509 if (!ascii_file) 518 if (is_bad(ascii_file))
510 goto out_bin; 519 goto out_bin;
511 520
512 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL); 521 ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);