ima: return dentry name if mnt is NULL
This patch returns dentry name if mnt is NULL.
Symbolic links checking hook does not have mnt.
Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index 69acb78..a5938c8 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -329,9 +329,12 @@
const char *ima_d_path(struct path *path, char **pathbuf)
{
char *pathname = NULL;
+ struct dentry *dentry = path->dentry;
- if (!path->mnt)
+ if (!dentry)
return NULL;
+ if (!path->mnt)
+ goto out;
/* We will allow 11 spaces for ' (deleted)' to be appended */
*pathbuf = kmalloc(PATH_MAX + 11, GFP_KERNEL);
@@ -343,5 +346,6 @@
pathname = NULL;
}
}
- return pathname ?: (const char *)path->dentry->d_name.name;
+out:
+ return pathname ?: (const char *)dentry->d_name.name;
}