@@ -74,28 +74,34 @@ static void seqbuf_seek(struct seqbuf *seqbuf, ssize_t offset)
static const char *get_filename(struct tegra_bpmp *bpmp,
const struct file *file, char *buf, int size)
{
- char root_path_buf[512];
+ char *root_path_buf;
const char *root_path;
- const char *filename;
+ const char *filename = NULL;
size_t root_len;
+ root_path_buf = kzalloc(512, GFP_KERNEL);
+ if (!root_path_buf)
+ goto out;
+
root_path = dentry_path(bpmp->debugfs_mirror, root_path_buf,
sizeof(root_path_buf));
if (IS_ERR(root_path))
- return NULL;
+ goto out;
root_len = strlen(root_path);
filename = dentry_path(file->f_path.dentry, buf, size);
if (IS_ERR(filename))
- return NULL;
+ goto out;
if (strlen(filename) < root_len ||
strncmp(filename, root_path, root_len))
- return NULL;
+ goto out;
filename += root_len;
+out:
+ kfree(root_path_buf);
return filename;
}