From: Richard Weinberger Date: Tue, 3 Mar 2015 22:41:52 +0000 (+0100) Subject: hostfs: Add a BUG_ON to detect behavior changes of dentry_path_raw() X-Git-Tag: v4.1-rc1~121^2~20 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=aad50b1e06081de0e4ff25335ab6f52e58bfcef1;p=karo-tx-linux.git hostfs: Add a BUG_ON to detect behavior changes of dentry_path_raw() 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 --- diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 67e556cbfd82..3082a7e715dd 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -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);