Commit 0600597c authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Linus Torvalds
Browse files

kasan: initialize tag to 0xff in __kasan_kmalloc

When building with -Wuninitialized and CONFIG_KASAN_SW_TAGS unset, Clang

mm/kasan/common.c:484:40: warning: variable 'tag' is uninitialized when
used here [-Wuninitialized]
        kasan_unpoison_shadow(set_tag(object, tag), size);

set_tag ignores tag in this configuration but clang doesn't realize it at
this point in its pipeline, as it points to arch_kasan_set_tag as being
the point where it is used, which will later be expanded to (void
*)(object) without a use of tag.  Initialize tag to 0xff, as it removes
this warning and doesn't change the meaning of the code.

Fixes: 7f94ffbc

 ("kasan: add hooks implementation for tag-based mode")
Signed-off-by: default avatarNathan Chancellor <>
Reviewed-by: default avatarAndrey Konovalov <>
Reviewed-by: default avatarAndrey Ryabinin <>
Cc: Alexander Potapenko <>
Cc: Dmitry Vyukov <>
Cc: Nick Desaulniers <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent bb9f6f63
......@@ -464,7 +464,7 @@ static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object,
unsigned long redzone_start;
unsigned long redzone_end;
u8 tag;
u8 tag = 0xff;
if (gfpflags_allow_blocking(flags))
Supports Markdown
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