Commit 88391d49 authored by Richard Cochran's avatar Richard Cochran Committed by Greg Kroah-Hartman

kernfs: fix off by one error.

The hash values 0 and 1 are reserved for magic directory entries, but
the code only prevents names hashing to 0. This patch fixes the test
to also prevent hash value 1.
Signed-off-by: default avatarRichard Cochran <richardcochran@gmail.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 13df7977
...@@ -190,7 +190,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns) ...@@ -190,7 +190,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns)
hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31)); hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31));
hash &= 0x7fffffffU; hash &= 0x7fffffffU;
/* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */ /* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */
if (hash < 1) if (hash < 2)
hash += 2; hash += 2;
if (hash >= INT_MAX) if (hash >= INT_MAX)
hash = INT_MAX - 1; hash = INT_MAX - 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment