[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>
This commit is contained in:
committed by
Linus Torvalds
parent
ed5a92700d
commit
ca4a031f6b
@@ -487,26 +487,35 @@ struct file_operations tpm_binary_bios_measurements_ops = {
|
|||||||
.release = tpm_bios_measurements_release,
|
.release = tpm_bios_measurements_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int is_bad(void *p)
|
||||||
|
{
|
||||||
|
if (!p)
|
||||||
|
return 1;
|
||||||
|
if (IS_ERR(p) && (PTR_ERR(p) != -ENODEV))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct dentry **tpm_bios_log_setup(char *name)
|
struct dentry **tpm_bios_log_setup(char *name)
|
||||||
{
|
{
|
||||||
struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
|
struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
|
||||||
|
|
||||||
tpm_dir = securityfs_create_dir(name, NULL);
|
tpm_dir = securityfs_create_dir(name, NULL);
|
||||||
if (!tpm_dir)
|
if (is_bad(tpm_dir))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
bin_file =
|
bin_file =
|
||||||
securityfs_create_file("binary_bios_measurements",
|
securityfs_create_file("binary_bios_measurements",
|
||||||
S_IRUSR | S_IRGRP, tpm_dir, NULL,
|
S_IRUSR | S_IRGRP, tpm_dir, NULL,
|
||||||
&tpm_binary_bios_measurements_ops);
|
&tpm_binary_bios_measurements_ops);
|
||||||
if (!bin_file)
|
if (is_bad(bin_file))
|
||||||
goto out_tpm;
|
goto out_tpm;
|
||||||
|
|
||||||
ascii_file =
|
ascii_file =
|
||||||
securityfs_create_file("ascii_bios_measurements",
|
securityfs_create_file("ascii_bios_measurements",
|
||||||
S_IRUSR | S_IRGRP, tpm_dir, NULL,
|
S_IRUSR | S_IRGRP, tpm_dir, NULL,
|
||||||
&tpm_ascii_bios_measurements_ops);
|
&tpm_ascii_bios_measurements_ops);
|
||||||
if (!ascii_file)
|
if (is_bad(ascii_file))
|
||||||
goto out_bin;
|
goto out_bin;
|
||||||
|
|
||||||
ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
|
ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
|
||||||
|
Reference in New Issue
Block a user