diff options
author | Andrew Morton <akpm@osdl.org> | 2006-02-01 06:05:01 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-01 11:53:11 -0500 |
commit | ca4a031f6b43edb8745ebc0a1b7307c24719dae4 (patch) | |
tree | fdbd3953c93828e588421afb7e07869c520013f4 | |
parent | ed5a92700d3ce2646cb7763792a5f7ad1bade7e8 (diff) |
[PATCH] tpm_bios: securityfs error checking fix
These functions return ERR_PTR()s on error, not NULL.
Spotted by Randy.
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Kylene Jo Hall <kjhall@us.ibm.com>
Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/char/tpm/tpm_bios.c | 15 |
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 | ||
490 | static 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 | |||
490 | struct dentry **tpm_bios_log_setup(char *name) | 499 | struct 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); |