Skip to content

Commit

Permalink
hostfs: Add a BUG_ON to detect behavior changes of dentry_path_raw()
Browse files Browse the repository at this point in the history
hostfs' __dentry_name() relies on the fact that dentry_path_raw() will place
the path name at the end of the provided buffer.
While this is okay, add a BUG_ON() to detect behavior changes as soon
as possible.

Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Richard Weinberger committed Mar 26, 2015
1 parent 41761dd commit aad50b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ static char *__dentry_name(struct dentry *dentry, char *name)
__putname(name);
return NULL;
}

/*
* This function relies on the fact that dentry_path_raw() will place
* the path name at the end of the provided buffer.
*/
BUG_ON(p + strlen(p) + 1 != name + PATH_MAX);

strlcpy(name, root, PATH_MAX);
if (len > p - name) {
__putname(name);
Expand Down

0 comments on commit aad50b1

Please sign in to comment.