summaryrefslogtreecommitdiff
path: root/include/linux/string.h
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2017-12-29 19:49:13 +0300
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2017-12-29 19:49:13 +0300
commit70a02f840c5113cd9255ce4c1b1848bb48b0bd21 (patch)
tree1cd859500e4db4f4c44dadd908ce88c9b3f2a2b6 /include/linux/string.h
parent5f215d252496543ba22299bccef5062d30d63cfe (diff)
parent464e1d5f23cca236b930ef068c328a64cab78fb1 (diff)
downloadlinux-70a02f840c5113cd9255ce4c1b1848bb48b0bd21.tar.xz
Merge tag 'v4.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into fbdev-for-next
Linux 4.15-rc5
Diffstat (limited to 'include/linux/string.h')
-rw-r--r--include/linux/string.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/string.h b/include/linux/string.h
index 54d21783e18d..cfd83eb2f926 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
@@ -258,7 +259,10 @@ __FORTIFY_INLINE __kernel_size_t strlen(const char *p)
{
__kernel_size_t ret;
size_t p_size = __builtin_object_size(p, 0);
- if (p_size == (size_t)-1)
+
+ /* Work around gcc excess stack consumption issue */
+ if (p_size == (size_t)-1 ||
+ (__builtin_constant_p(p[p_size - 1]) && p[p_size - 1] == '\0'))
return __builtin_strlen(p);
ret = strnlen(p, p_size);
if (p_size <= ret)